不幸的是, 您没有成功进入前 25, 但您进入了前 500, 排名 p。
现在, 8VC 冒险杯2017的淘汰回合正在举行。已宣布, Codecraft-17 t恤优胜者将选择如下。让 s 是8VC 冒险投资杯2017的淘汰回合获胜者的点数。然后将执行以下伪代码:
i := (s div 50) mod 475
repeat 25 times:
i := (i * 96 + 42) mod 475
print (26 + i)
这里的 "div" 是整数除法运算符, "mod" 是模 (除法的余数) 运算符。
由于伪代码执行,会生成在26和500之间的25个整数,并打印。这些名次的参加者将得到 Codecraft-17 t恤衫。确保25打印的整数对 s的任何值都是不同的。
您处于8VC 冒险杯2017的淘汰回合的领先地位, 具有 x 点。您认为在当前回合中至少具有 y 点将足以赢得胜利。
为了改变你的最后成绩, 你可以做任何数量的成功和失败。成功会给你带来100分, 失败会扣你50分。
你想赢得目前的回合, 并在同一时间, 确保得到一个 Codecraft-17 t恤衫。要实现此目的, 您必须成功的最小数目是多少?
唯一的行包含三个整数 p, x 和 y (26 ≤ p ≤ 500;1 ≤ y ≤ x ≤ 20000)-你在 Codecraft-17 的位置, 你目前在淘汰回合8VC 冒险杯 2017, 以及你认为足够的点数, 以赢得当前回合的分数。
输出一个整数-你必须做的成功的最小数量, 使自己赢得淘汰回合8VC 冒险杯 2017, 并确保得到一个 Codecraft-17 t恤衫。
保证您的目标对于任何有效的输入数据都是可以实现的。
239 10880 9889
0
26 7258 6123
2
493 8000 8000
24
101 6800 6500
0
329 19913 19900
8
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.
#include<iostream>
using namespace std;
bool judge(int p,int s)
{
int i=(s/50)%475;
for(int j=0;j<25;j++)
{
i=(i*96+42)%475;
if(i+26==p)
return true;
}
return false;
}
int main()
{
int p,x,y;
while(cin >> p >> x >> y)
{
bool flag=false;
int fin=x,add=0;
while(fin>=y)
{
if(judge(p,fin))
{
cout << 0 << endl;
flag=true;
break;
}
fin-=50;
}
if(flag)
continue;
do
{
add+=50;
}while(!judge(p,x+add));
if(add%100==0)
cout << add/100 << endl;
else
cout << add/100+1 << endl;
}
return 0;
}
最难的还是理解题意.......