why?第三点错了,求大佬帮忙,感激不尽

P1150 Peter 的烟

```cpp #include<iostream> using namespace std; int main() { int n,k,s; cin>>n>>k; s=n; while(n>=k) { n=n-k; n=n+1; s=s+1; } cout<<s<<endl; return 0; } ```
by 市场花园行动 @ 2017-10-06 21:44:48


额,是c++的,不好意思....
by 市场花园行动 @ 2017-10-06 21:45:18


```cpp var n,k,sum:longint; begin read(n,k); sum:=n; while sum=sum do begin n:=n-k+1; inc(sum); if n<k then break; end; write(sum); end. ```
by ljxljxljx @ 2017-10-08 20:26:13


用减法,慢慢来。
by ljxljxljx @ 2017-10-08 20:26:55


@[lcf3241142097](/space/show?uid=37601) 小心边缘数据 这个是w#3的代码 ```cpp #include<cstdio> using namespace std; int main() { int n,k,count,countt; scanf("%d%d",&n,&k); count=n; countt=n; while(countt>k) { countt-=k; countt++; count++; } printf("%d",count); return 0; } countt>k改成countt>=k就A了 ```
by bh1234666 @ 2017-11-24 20:15:45


|