Codeforces Round #412 B. T-Shirt Hunt (暴力枚举)
来源:互联网 发布:java代理机制 编辑:程序博客网 时间:2024/06/05 16:19
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 placep.
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. Lets 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, havingx points. You believe that having at leasty 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?
The only line contains three integers p,x andy (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 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.
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.
题意:给出前一次比赛的排名p和分数x,再给出目标要超过的分数y。现在要抽取25个送衣服然后给出抽取的规则
问至少hack成功多少次才能得到衣服,hack成功一次加100分,失败一次减50,失败的不计入次数。
分析:暴力枚举就可以了,首先分数要高于y,然后从x 开始hack失败让分数靠近y,每次减50,看是否成立
因为hack失败是不计入次数的。
如果上诉条件没能成立,再让分数向上涨,每次要判断hack成功一次,和成功后再失败一次的情况。
AC代码:
#include<stdio.h>#include<string.h>#define mod 475int ans;bool vj(int s,int p){s=(s/50)%mod;for(int i=0;i<25;i++){s=(s*96+42)%mod;if(s+26==p)return true;}return false;}void solve(int p,int x,int y){int nx=x;while(nx>=y) //hack unsuccess;{if(vj(nx,p)){printf("%d\n",ans);return;}nx-=50;}//printf("!!\n");while(!vj(x,p)){x+=50;//hack successans++;if(vj(x,p)){printf("%d\n",ans);return;}x+=50;//hack unsuccess}printf("%d\n",ans);return;}int main(){int p,x,y;scanf("%d%d%d",&p,&x,&y);ans=0;while(x<y){x+=100;ans++;}solve(p,x,y);}
- Codeforces Round #412 B. T-Shirt Hunt (暴力枚举)
- Codeforces Round #412 B. T-Shirt Hunt
- codeforces T-Shirt Hunt(傻瓜暴力)
- codeforces 412 B T-shirt Hunt
- 【Codeforces 807 B. T-Shirt Hunt】
- codeforces round #412 B. T-shirt buying
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) B. T-Shirt Hunt(模拟)
- B. T-Shirt Hunt
- 小白题解 Codeforces 807B T-Shirt Hunt
- Codeforces807 B. T-Shirt Hunt
- 807B T-Shirt Hunt
- Codeforces Round #413 B. T-shirt buying
- Codeforces Round #413 B. T-shirt buying
- CF#807 B. T-Shirt Hunt(水题)
- CodeForces 799B (B) T-shirt buying
- Codeforces Round #243 (Div. 2) A,B,C(暴力枚举)
- Codeforces Round #392(Div. 2) B Blown Garland【暴力枚举】
- Codeforces Round #402 (Div. 2)B. Weird Rounding【暴力枚举】
- 如何破解myeslipse
- 体验套餐管理系统
- java时间操作大全
- SQL 诞生 43 年了!为什么我们仍在使用它的 8 个原因
- How can you disable the UDDI and UDDI Explorer functionality in WebLogic Server? (Doc ID 1274906.1)
- Codeforces Round #412 B. T-Shirt Hunt (暴力枚举)
- 移动端点赞评论
- 项目经理评分(评价)
- loadrunner的socket协议各函数解释,使用方法和场景(慢慢补充,见谅)
- 考勤信息(员工打卡)
- iOS 文字动画
- 图片懒加载
- MySQL分区
- innerHTML和createTextNode的区别