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.

解题思路:

这道题就跟吸了毒一样,刚开始一直读错了题,没看清那个公式的作用,以为那25个名次是固定的,第二天补题才发现那是根据"s"变化的,而"s"代表的就是输入的"x",读准题目后这道题就好做了。题目要就最少hack的次数

首先:先进行判断:如果名次正好为那二十五个之中的,则直接输出就行,

反之进行下一步: 由题知,所求需要成功的hack最少,那么每次增加成功hack次数之前都应考虑是否可以在s不小于y的情况下,通过不断hack失败,达到那25个位置

稍微分析下,便可得到思路,主要是读题太恶心了,这题目真心有毒

下面是实现代码:

#include<bits/stdc++.h>
using namespace std; int main()
{
int p,s,y,i,j,ans=;
cin>>p>>s>>y;
while()
{
i = (s / ) % ;
for(j = ;j < ;j ++){
i = (i * + ) % ;
if( + i == p)
{
cout<<ans<<endl;
return ;
}
}
int t = s,k,l;
t -= ;
while(t >= y)
{
k = (t / ) % ;
for(j = ;j < ;j ++)
{
k = (k * + )%;
if( + k == p)
{
cout<<ans<<endl;
return ;
}
}
t -= ;
}
s += ;
ans++;
}
}

Codeforces Round #412 B. T-Shirt Hunt的更多相关文章

  1. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3)(A.B.C,3道暴力题,C可二分求解)

    A. Is it rated? time limit per test:2 seconds memory limit per test:256 megabytes input:standard inp ...

  2. Codeforces Round#412 Div.2

    A. Is it rated? 题面 Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codefo ...

  3. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A B C D 水 模拟 二分 贪心

    A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  4. Codeforces Round #412 Div. 2 第一场翻水水

    大半夜呆在机房做题,我只感觉智商严重下降,今天我脑子可能不太正常 A. Is it rated? time limit per test 2 seconds memory limit per test ...

  5. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) D - Dynamic Problem Scoring

    地址:http://codeforces.com/contest/807/problem/D 题目: D. Dynamic Problem Scoring time limit per test 2 ...

  6. Codeforces Round #412 A Is it rated ?

    A. Is it rated? time limit per test  2 seconds memory limit per test  256 megabytes Is it rated? Her ...

  7. Codeforces Round #412 Div. 2 补题 D. Dynamic Problem Scoring

    D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  8. Codeforces Round #412 C. Success Rate

    C. Success Rate time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  9. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A Is it rated?

    地址:http://codeforces.com/contest/807/problem/C 题目: C. Success Rate time limit per test 2 seconds mem ...

随机推荐

  1. TCP/IP协议---广播和多播及IGMP协议

    老板找某个高层谈话,这是一对一形式.当老板叫来所有高层谈话,那么就变为了一对多.计算机网络中也是如此,当一个主机需要和更多机器对话时,就有了广播和多播这种形式. 广播和多播仅应用于UDP,它们对需将报 ...

  2. php和js字符串的acsii码函数

    简单普及下编码知识: javascript中有charCodeAt(),根据字符查找ascii码. String.fromCharCode(),根据ascii码查找对应的字符. console.log ...

  3. React-理解Redux

    Redux是什么? 是专于状态管理的库 专于状态管理和react解耦 单一状态,单项数据流 核心概念 store state action reducer Redux工作流 react 要改变stor ...

  4. Vue-嵌套路由

    一个被渲染组件同样可以包含自己的嵌套 <router-view>.同样要有vue-router的三个要素:路由map .路由视图.路由导航. 举个在"/apple" 下 ...

  5. 线程池(ThreadPool)

    线程池概述 由系统维护的容纳线程的容器,由CLR控制的所有AppDomain共享.线程池可用于执行任务.发送工作项.处理异步 I/O.代表其他线程等待以及处理计时器. 线程池与线程 性能:每开启一个新 ...

  6. 值类型和引用类型的区别,struct和class的区别

    C#值类型和引用类型 1.简单比较 值类型的变量直接存储数据,而引用类型的变量持有的是数据的引用,数据存储在数据堆中. 值类型(value type):byte,short,int,long,floa ...

  7. Wechat login authorization(OAuth2.0)

    一.前言 昨天小组开了个会,让我今天实现一个微信网页授权的功能,可以让用户在授权之后无需再次登录既可进入用户授权界面.在这之前我也从没接触过微信公众号开发之类的,也不知道公众号后台是啥样子的,自己所在 ...

  8. dpkg:错误:正在解析文件 '/var/lib/dpkg/updates/0014' 第 0 行附近:在字段名 #padding 中有换行符问题的解决方法

    解决方案如下: sudo rm /var/lib/dpkg/updates/* sudo apt-get update python@ubuntu:~/Desktop/_Welcome_.jpg.ex ...

  9. BZOJ3782 上学路线

    设障碍个数为,\(obs\)则一般的容斥复杂度为\(O(2^{obs})\).但因为这个题是网格图,我们可以用DP解.设\(f[i]\)表示不经过任何障碍到达第\(i\)个障碍的方案数,转移时枚举可以 ...

  10. 网易云课堂-----Linux内核分析-----期末主观题

    姚歌 + 原创作品转载请注明出处 + <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 下面是对8个课题的 ...