dherorunner @ 2016-08-17 21:24:18
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int n;//烟数
cin>>n;
int k;//k个烟蒂换一个烟
cin>>k;
int m=0;//烟蒂数
while(n--)//每抽一支烟
{
m++;//就多一个烟蒂
if(m%k==0)//攒够了新的k支烟
{
n++;
}
else if(n==0)
break;
}
cout<<m;//共产生的烟蒂数
return 0;
}
by acacqac @ 2016-08-23 14:54:17
?
by 2bsb2b @ 2016-10-07 14:27:16
这就OK了
#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;
}
by homi @ 2024-10-26 17:18:35
考古