panjidongc @ 2015-08-09 14:01:08
我Peter的烟这题总是90分(第三个点过不去),大家帮我找找错。代码如下:
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int n,k,ans=0;
scanf("%d%d",&n,&k);
ans+=n;
while(n>=k)
{
n/=k;
ans+=n;
}
printf("%d",ans);
return 0;
}
by h__a_ny @ 2015-08-09 14:46:40
程序应为:
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int n,k,ans=0;
scanf("%d%d",&n,&k);
ans+=n;
while(n>=k)
{
ans=ans+n/k;
n=n/k+n%k;
}
printf("%d",ans);
return 0;
}
错因:每一次用烟蒂换烟,可以换n/k根烟,但还有n%k个烟蒂不能丢,之后可能会有用
by panjidongc @ 2015-08-09 15:17:40
谢谢,问题已更正。
by Rieman_sum @ 2023-02-20 20:05:37
考古
by huangruinan123456 @ 2024-01-08 21:35:35
考古