Codeforces Round #412 B. T-Shirt Hunt(模拟)

原题地址:http://codeforces.com/problemset/problem/807/B

题意:给出前一次比赛的排名p和分数x,再给出目标要超过的分数y。现在要抽取25个送衣服然后给出抽取的规则问至少hack成功多少次才能得到衣服,hack成功一次加100分,失败一次减50,失败的不计入次数。

思路:xjb模拟就行了.

首先如果分数不够,那么肯定只能先把分数加上去然后再考虑别的.

如果分数够了,我们每次加50判断,因为成功+100,失败-50,所以每次判断分数间距是50

#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <cctype>
#define eps 1e-8
#define INF 0x3f3f3f3f
#define MOD 1e9+7
#define PI acos(-1)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define CLR(x,y) memset((x),y,sizeof(x))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 4005;
int p, x, y;

bool f(int s) {
    int i = s / 50;
    i %= 475;
    for(int j = 1; j <= 25; j++) {
        i = (i * 96 + 42) % 475;
        if(i + 26 == p) return 1;
    }
    return 0;
}
int main() {
    scanf("%d%d%d", &p, &x, &y);
    int ans = 0;
    while(x < y) {//如果分数还不够,就先把分数加上去
        x += 100;
        ans++;
    }
    int nx = x;
    while(nx >= y) {//判断当前比y稍微大一点的x是否可行
        if(f(nx)) {
            printf("%d\n", ans);
            return 0;
        }
        nx -= 50;
    }
    while(1) {//每次+100判断
        ans++;
        if(f(x + 50) || f(x + 100)) {
            printf("%d\n", ans);
            return 0;
        }
        x += 100;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/yiqzq/article/details/81437001
今日推荐