好久没做到ACM了,最近都在搞SHELL编程,和latex去了。
题目link:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1001&cid=500
题目的意思非常简单也很好想,但是我WA了好多次,原因:一直都用lld,换成I64d就通过了。
主要考虑就是不递增就输出-1;其余就模拟,水到不行。
另外,如果不相信lld会WA的同学自己尝试吧。
/*************************************************************************
> OS : Linux 3.2.0-60-generic #91-Ubuntu
> Author : yaolong
> Mail : dengyaolong@yeah.net
> Created Time: 2014年05月18日 星期日 15:59:55
************************************************************************/
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
int T;
scanf("%d",&T);
long long n,m,v,k;
while(T--){
scanf("%I64d%I64d%I64d%I64d",&n,&m,&v,&k);
if(n<=m){
puts("0");
continue;
}
if(m>=(m-v)*k){
puts("-1");
continue;
}
int cnt=0;
while(m<n){
m=(m-v)*k;
cnt++;
}
printf("%d\n",cnt);
}
}