shuyingxuejing @ 2016-10-08 16:30:57
#include<iostream>
using namespace std;
int a,b,s,d;
int main()
{
cin>>a>>b;
while(a>0)
{
a--;
s++;
if(s>=b)
{
s-=b;
a++;
}
d++;
}
cout<<d;
}
by nuclear @ 2016-10-08 23:56:30
1<=n,k<=10^8
int 无法承受
改用long long 就好了
by 浮云启心 @ 2016-11-13 22:05:31
递归
by 46days @ 2016-11-14 10:58:50
int 可以承受
根本不用递归
by Suiseiseki @ 2016-12-21 22:27:00
这样吧,优化一下
#include<bits/stdc++.h>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstdlib>
#include<string>
#include<iomanip>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
int n,ans=0,k;
scanf("%d%d",&n,&k);
while(n>=k){
ans+=k;
n-=k;
++n;
}
ans+=n;
printf("%d\n",ans);
return 0;
}
by WuMin4 @ 2024-08-08 17:00:05
烤股