Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) B. T-Shirt Hunt

Posted dy blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) B. T-Shirt Hunt相关的知识,希望对你有一定的参考价值。

B. T-Shirt Hunt
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
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
239 10880 9889
output
0
input
26 7258 6123
output
2
input
493 8000 8000
output
24
input
101 6800 6500
output
0
input
329 19913 19900
output
8
Note
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 343
In 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.
技术分享
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int p,x,y,a[26];
 4 bool init(int s)
 5 {
 6     int i=s/50%475;
 7     for (int j=0;j<25;j++)
 8     {
 9         i=(i*96+42)%475;
10         if (26+i==p) return true;
11     }
12     return false;
13 }
14 int main() 
15 {
16     scanf("%d%d%d",&p,&x,&y);
17     for(int i=x;i>=y;i-=50)
18     {
19         if(init(i))
20         {
21             puts("0");
22             return 0;
23         }
24     }
25     for(int i=x,j=0;;i+=100,j++)
26     {
27         if(init(i) || init(i-50))
28         {
29             printf("%d\n",j);
30             return 0;
31         }
32     }
33     return 0;
34 }
被终审数据黑掉的代码

挂了的样例:

180 4213 4207
因为后面i-50会出现4213-50<4207,但还是输出了0

技术分享
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int p,x,y,a[26];
 4 bool init(int s)
 5 {
 6     int i=s/50%475;
 7     for (int j=0;j<25;j++)
 8     {
 9         i=(i*96+42)%475;
10         //printf("%d ",26+i);
11         if (26+i==p) return true;
12     }
13     //printf("\n");
14     return false;
15 }
16 int main() 
17 {
18     scanf("%d%d%d",&p,&x,&y);
19     for(int i=x;i>=y;i-=50)
20     {
21         if(init(i))
22         {
23             puts("0");
24             return 0;
25         }
26     }
27     for(int i=x+100,j=1;j<500;i+=100,j++)
28     {
29         if(init(i) || init(i-50))
30         {
31             printf("%d\n",j);
32             return 0;
33         }
34     }
35     return 0;
36 }
AC代码

 




以上是关于Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) B. T-Shirt Hunt的主要内容,如果未能解决你的问题,请参考以下文章

VK Cup 2017 Round 3 + Codeforces Round #412

Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) E. Prairie Partition 二分+贪心

Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) B. T-Shirt Hunt

Codeforces Global Round 19

Codeforces Educational Codeforces Round 67

Codeforces Round 1132Educational Round 61