不用for,直接判断。
上代码!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include<bits/stdc++.h>
using namespace std;
long long n,r,b,ans,n2;
int main()
{
cin>>n>>r>>b;
ans=r*(n/(r+b));
n2=n%(r+b);
if(n2==0) cout<<ans;
else if(n2<r) cout<<ans+n2;
else cout<<ans+r;
return 0;
}
欢迎参考