hdu_4823_Energy Conversion
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4823
题意:中文题,很清楚,要注意的是乘起来会爆int
题解:
1 #include<cstdio> 2 int main(){ 3 long long t,n,m,v,k,ans,pre; 4 scanf("%d",&t); 5 while(t--){ 6 scanf("%I64d%I64d%I64d%I64d",&n,&m,&v,&k); 7 if(m>=n)printf("0\n"); 8 else{ 9 ans=0,pre=-1; 10 while(m<n&&m>=v&&pre!=m){pre=m,m=(m-v)*k,ans++;} 11 if(m>=n)printf("%I64d\n",ans); 12 else printf("-1\n"); 13 } 14 } 15 return 0; 16 }