2014年百度之星程序设计大赛

小记:long long %I64d


代码:

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>


using namespace std;


#define mst(a,b) memset(a,b,sizeof(a))
#define eps 10e-8


const int MAX_ = 10010;
const int N = 100010;
const int INF = 0x7fffffff;




int main(){
    long long T, n, m, v, k, pre, cnt;
    scanf("%I64d", &T);
    while(T--){
        scanf("%I64d%I64d%I64d%I64d", &n, &m, &v, &k);
        cnt = 0;
        while(m > -1 && m < n){
            pre = m;
            m = (m - v) * k;
            cnt++;
            if(m <= pre)m = -1;
        }
        if(m < 0){
            cnt = -1;
        }
        printf("%I64d
", cnt);
    }
    return 0;
}

原文地址:https://www.cnblogs.com/wzjhoutai/p/7113013.html