CodeForces

来源:互联网 发布:ios多线程编程 面试 编辑:程序博客网 时间:2024/06/05 17:02

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 475repeat 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 xpoints. 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 px and y (26 ≤ p ≤ 5001 ≤ 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.

Example
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.


题意:

   首先题目很长很长很长,题中的那一段代码测试一下,发现是x代入s得到的

也就是输入的三个数p,x,y,要满足由x得到的25个元素中有p,而且x要大于等于y,其中x可以变,答对一题+100,答错一题-50

求答对题目最少的个数使得由x得到的25个元素中含有p.

思路:

大致是按照题意直接来写,中间注意一点,当x大于y的时候可以让x减小,这样如果有符合条件的,最后结果是0,

写的过程中用到了二分查找元素,是库函数里的lower_bound,注意循环的控制就好了

#include <iostream>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <algorithm>#include <math.h>using namespace std;int data[25];int main(){   int p,x,y,a;   while(~scanf("%d%d%d",&p,&x,&y))   {        a=0;        int xx=x,yy=y;        if(xx>=yy)        {            int aa=(xx-yy)/50;            int f=0;            for(int h=0;h<=aa;h++)            {                xx=xx-50;                int i=(xx/50)%475;       for(int j=0;j<25;j++)       {           i=(i*96+42)%475;           data[j]=i+26;       }       for(int y=0;y<25;y++)       //cout<<data[y]<<" ";      // cout<<endl;       sort(data,data+25);       int ans=lower_bound(data,data+25,p)-data;                if(data[ans]==p&&xx>=yy)                {                    f=1;printf("0\n");//cout<<"xx="<<xx<<endl;                    break;                }            }            if(f==1)continue;        }       if(x<y)       {            a=(y-x)/50;           if((y-x)%50>0)a++;           x=x+a*50;       }       int sum=a;       while(1)       {    //cout<<"x="<<x;           int i=(x/50)%475;       for(int j=0;j<25;j++)       {           i=(i*96+42)%475;           data[j]=i+26;       }      // for(int y=0;y<25;y++)       // cout<<data[y]<<" ";       sort(data,data+25);       int ans=lower_bound(data,data+25,p)-data;      //cout<<"ans="<<ans<<endl;       if(data[ans]==p)       {    //cout<<"sum="<<sum<<endl;           int b=sum/2;           if(sum%2==1)            b++;//cout<<"x="<<x<<endl;           printf("%d\n",b);           break;       }       x+=50;       sum++;       }   }    return 0;}



原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 失业就业登记证怎么办? 如果父母是教师怎么办 老人档案丢了怎么办 想离婚想要孩子怎么办 一二年级成绩差怎么办 高考复读又失败怎么办 孩子不想估成绩怎么办 手机信号被屏蔽了怎么办 西安市旅游年卡怎么办 广电宽带网速慢怎么办 电视智能卡坏了怎么办 家乐卡二次授信怎么办? 邢台银行倒闭了怎么办 不敢和导师交流怎么办 考上一个破大学怎么办 腻子粉检测报告怎么办 电子厂插件很慢怎么办 预付费电表跳闸怎么办 电费有疑问怎么办大连 农村电表箱坏了怎么办 农村电表没电怎么办 家里电费特别高怎么办 电表读卡失败怎么办 电表卡消磁了怎么办 智能表采集失败怎么办 电脑没有蓝牙功能怎么办 判决后无力偿还怎么办 dz47-63c63跳闸怎么办 租房合同丢了怎么办 北京土地承包合同丢失怎么办 租赁合同丢失了怎么办 房屋租赁合同丢失怎么办 学校没发学生证怎么办 学校银行卡丢了怎么办 报税名字忘了怎么办 地税零申报漏报怎么办 欠中联重科施工电梯钱怎么办 大型船舶起锚正横后怎么办 老师不会教孩子怎么办 个体工商营业证怎么办 广州市住房公积怎么办