B. T-Shirt Hunt
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard 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 ofsuccessful hacks you have to do to achieve that?

Input

The only line contains three integers px 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.

题意:

给出p,x,y 。你可以通过给x+100,-50两种操作,使x和p满足以下两个条件:

1、x>=y

2、注:(x即下方的s)

p在下方运算输出的25个数中出现过

i := (s div 50) mod 475
repeat 25 times:
i := (i * 96 + 42) mod 475
print (26 + i)

问最少执行多少次+100的操作

首先判断,若x>=y,那就先只执行-50的操作

看在x>y的前提下能否只-50就满足要求

否则,再x>y的前提下 先给x+100,判断,再-50,判断

循环直至x满足要求

为什么只减1个50?

若减2个50,那就不用+这个100,若减3个50,在上一次-50就算过了,以此类推

#include<cstdio>
using namespace std;
int p,x,y,ans;
bool check(int s)
{
int i=s/%;
for(int j=;j<=;j++)
if((i*%+)%+==p) return true;
else i=(i*%+)%;
return false;
}
int main()
{
scanf("%d%d%d",&p,&x,&y);
int t=x;
while(x>=y)
{
if(check(x)) { printf("%d",ans); return ; }
x-=;
}
x=t;
while()
{
ans++;
x+=;
if(x<y) continue;
if(check(x)) { printf("%d",ans); return ;}
x-=;
if(check(x)) { printf("%d",ans); return ;}
x+=;
}
}

Codeforces 807 B T-Shirt Hunt的更多相关文章

  1. Codeforces Round #412 B. T-Shirt Hunt

    B. T-Shirt Hunt time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  2. Codeforces 807 C. Success Rate

    http://codeforces.com/problemset/problem/807/C C. Success Rate time limit per test 2 seconds memory ...

  3. Codeforces 807 A Is it rated?

    http://codeforces.com/problemset/problem/807/A A. Is it rated? time limit per test              2 se ...

  4. codeforces 807 E. Prairie Partition(贪心+思维)

    题目链接:http://codeforces.com/contest/807/problem/E 题意:已知每个数都能用x=1 + 2 + 4 + ... + 2k - 1 + r (k ≥ 0, 0 ...

  5. codeforces 807 D. Dynamic Problem Scoring(贪心+思维)

    题目链接:http://codeforces.com/contest/807/problem/D 题意:对于动态计分的 Codeforces Round ,已知每题的 score 是根据 Round ...

  6. codeforces 807 C. Success Rate(二分)

    题目链接:http://codeforces.com/contest/807/problem/C 题意:记 AC 率为当前 AC 提交的数量 x / 总提交量 y .已知最喜欢的 AC 率为 p/q ...

  7. 【codeforces 807B】T-Shirt Hunt

    [题目链接]:http://codeforces.com/contest/807/problem/B [题意] 你在另外一场已经结束的比赛中有一个排名p; 然后你现在在进行另外一场比赛 然后你当前有一 ...

  8. Treasure Hunt CodeForces - 979B

    After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up wit ...

  9. Codeforces B. Mouse Hunt(强连通分解缩点)

    题目描述: Mouse Hunt time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

随机推荐

  1. alpha冲刺(事后诸葛亮)

    [设想和目标] Q1:我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的描述? "小葵日记"是为了解决18-30岁年轻用户在记录生活时希望得到一美体验友好 ...

  2. lintcode-496-玩具工厂

    496-玩具工厂 工厂模式是一种常见的设计模式.请实现一个玩具工厂 ToyFactory 用来产生不同的玩具类.可以假设只有猫和狗两种玩具. 您在真实的面试中是否遇到过这个题? Yes 样例 ToyF ...

  3. lintcode-480-二叉树的所有路径

    480-二叉树的所有路径 给一棵二叉树,找出从根节点到叶子节点的所有路径. 您在真实的面试中是否遇到过这个题? Yes 样例 给出下面这棵二叉树: 所有根到叶子的路径为: [ "1-> ...

  4. lintcode-427-生成括号

    427-生成括号 给定 n 对括号,请写一个函数以将其生成新的括号组合,并返回所有组合结果. 样例 给定 n = 3, 可生成的组合如下: "((()))", "(()( ...

  5. PHP SQL查询结果在页面上是乱码

    今天系统网页出现这样一个问题:下图左边类型栏数据是没显示出来 打印SQL查询的数据是有的 原因是:————> eval函数里'return '这一字符串一定要有空格哈,没有空格,这语句就是错的. ...

  6. CentOS 7 U盘安装问题解决

    最近期待以久的CentOS 7正式版终于发布了,在家里无聊,所以就打算在我的小Y上安装一下,由于笔记本原来有安装Windows 7 操作系统,考虑使用的需求,所以决定安装双系统: 1.         ...

  7. php框架中常用的设计模式

    1.单例模式 //单例模式 class Demo { private static $obj; private function __construct() { } private function ...

  8. SpringMVC 应知应会

    springMVC 是表现层技术,可以用来代替 struts2,下面是简略图:主要是处理器和视图,只有这两个部分需要编写代码. springMVC 三大组件:处理器映射器,处理器适配器,视图解析器. ...

  9. Java知识点整理(三)

    如何设计出高可用的分布式架构 分布式架构 CDN简介 分布式缓存和本地缓存区别 高并发场景常用技术解决方案 JVM优化示例 Docker和JVM区别 Java开发人员需要注意的五大Docker误区 D ...

  10. bzoj4569-萌萌哒

    题目 有一个长度为\(n\)的十进制数,用\(s\)表示.有\(m\)个限制条件,每个条件形如:\((l_1,r_1,l_2,r_2)\),表示\(s[l_1:r_1]=s[l_2:r_2]\). 现 ...