大神帮忙看看为什么80分

P1150 Peter 的烟

zztzuishuai @ 2016-03-18 20:04:48

program peter;
 var
   a,b,c:longint;
   begin
  readln(a,b);
 repeat
  c:=a+a div b;
a:=a mod b;
 until(a mod b<b);
 writeln(c);
 end.

by Hyle33ies @ 2016-03-18 21:32:15

var
  n,k,wn,s,ans:longint;
begin
  readln(n,k);
  while n>0 do
  begin
    inc(ans);
    inc(wn);
    dec(n);
    if wn=k then
    begin
      wn:=0;
      inc(n);
    end;
  end;
  writeln(ans);
end.

by zhanghuaitao @ 2016-03-18 21:37:09

什么题啊


by 2bsb2b @ 2016-10-07 14:31:22

until的判断条件错了

应该是n>=k;


by 2bsb2b @ 2016-10-07 14:33:12

#include <iostream> 
using namespace std; 
int n,k,s;
int main() 
{
    cin>>n>>k; 
    s=n;   
    while (n>=k)  
    {
        n=n-k+1; 
        s+=1; 
    }
    cout<<s;
    return 0; 
}
你的思路跟我的不同

|