1 #include<iostream> 2 using namespace std; 3 int u,d; 4 int sum(int t){ 5 if(t%2==0) 6 return (u-d)*t/2; 7 else 8 return u*(t/2+1)-d*t/2; 9 } 10 int main(){ 11 int t,n; 12 cin>>n>>u>>d; 13 for(t=1;sum(t)<n;) 14 t++; 15 cout<<t<<endl; 16 return 0; 17 }
循环-07. 爬动的蠕虫(15),布布扣,bubuko.com
原文地址:http://www.cnblogs.com/gnodidux/p/3820618.html