Not so long ago the Codecraft-17 contest was held on Codeforces. The top 25 participants, and additionally random 25 participants out of those who got into top 500, will receive a Codeforces T-shirt.
Unfortunately, you didn't manage to get into top 25, but you got into top 500, taking place p.
Now the elimination round of 8VC Venture Cup 2017 is being held. It has been announced that the Codecraft-17 T-shirt winners will be chosen as follows. Let s be the number of points of the winner of the elimination round of 8VC Venture Cup 2017. Then the following pseudocode will be executed:
i := (s div 50) mod 475 repeat 25 times: i := (i * 96 + 42) mod 475 print (26 + i)Here "div" is the integer division operator, "mod" is the modulo (the remainder of division) operator.
As the result of pseudocode execution, 25 integers between 26 and 500, inclusive, will be printed. These will be the numbers of places of the participants who get the Codecraft-17 T-shirts. It is guaranteed that the 25 printed integers will be pairwise distinct for any value of s.
You're in the lead of the elimination round of 8VC Venture Cup 2017, having x points. You believe that having at least y points in the current round will be enough for victory.
To change your final score, you can make any number of successful and unsuccessful hacks. A successful hack brings you 100 points, an unsuccessful one takes 50 points from you. It's difficult to do successful hacks, though.
You want to win the current round and, at the same time, ensure getting a Codecraft-17 T-shirt. What is the smallest number of successful hacks you have to do to achieve that?
Input
The only line contains three integers p, x and y (26 ≤ p ≤ 500; 1 ≤ y ≤ x ≤ 20000) — your place in Codecraft-17, your current score in the elimination round of 8VC Venture Cup 2017, and the smallest number of points you consider sufficient for winning the current round.
Output
Output a single integer — the smallest number of successful hacks you have to do in order to both win the elimination round of 8VC Venture Cup 2017 and ensure getting a Codecraft-17 T-shirt.
It's guaranteed that your goal is achievable for any valid input data.
Examples
Input
Copy
239 10880 9889Output
Copy
0Input
Copy
26 7258 6123Output
Copy
2Input
Copy
493 8000 8000Output
Copy
24Input
Copy
101 6800 6500Output
Copy
0Input
Copy
329 19913 19900Output
Copy
8Note
In the first example, there is no need to do any hacks since 10880 points already bring the T-shirt to the 239-th place of Codecraft-17 (that is, you). In this case, according to the pseudocode, the T-shirts will be given to the participants at the following places:
475 422 84 411 453 210 157 294 146 188 420 367 29 356 398 155 102 239 91 133 365 312 449 301 343In the second example, you have to do two successful and one unsuccessful hack to make your score equal to 7408.
In the third example, you need to do as many as 24 successful hacks to make your score equal to 10400.
In the fourth example, it's sufficient to do 6 unsuccessful hacks (and no successful ones) to make your score equal to 6500, which is just enough for winning the current round and also getting the T-shirt.
题意: 由上边题目中的代码生成中奖排名,给出p(排名),x(分数),y(最低中奖分数),问最少差多少分可以中奖0。从最低中奖分数开始枚举,给定的y范围到20000,但是枚举的时候要比20000多(Wa了一次),保险起见,不妨到30000。
还有需要注意的是,要保存下来枚举成立的值,以便比较与一开始给定的分数比较,若小于直接输出0即可。
AC Code:
#include<iostream> #include<iomanip> //#include<bits/stdc++.h> #include<cstdio> #include<cmath> #include<string> #include<algorithm> #include<cstring> #include<vector> #include<sstream> #include<queue> #include<set> #define PI 3.14159265358979 #define LL long long const LL MAX=1e5+1000; using namespace std; set<int> v; void judge(int x)//有分数生成的编号放入set中,以便验证 { x=(x/50)G5;int b; for(int i=1;i<=25;++i) { x=(x*96+42)G5; b=x+26; v.insert(b); } } int main() { // freopen("input.txt","r",stdin); ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,m,T; cin>>n>>m>>T; judge(m);//先判断一次 if(v.count(n)) {cout<<0;return 0;} int M=0x7fffffff;int MIN=0x7fffffff; for(int i=T;i<=30000;++i)//枚举 { v.clear();//每次清空 judge(i); if(v.count(n)) { int S=abs(i-m); if(SP==0) { if(S<M) {M=S;MIN=min(MIN,i);} } } } if(MIN<m) {cout<<0;return 0;} if(M0==0) cout<<M/100; else cout<<(M+50)/100; }