Codeforces Round #412 B. T-Shirt Hunt
来源:互联网 发布:股票买卖软件下载3.0 编辑:程序博客网 时间:2024/05/17 04:07
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 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 of successful hacks you have to do to achieve that?
题意
很有趣的题面,通过 successful hack 和 unsuccessful hack 增减 Round 的 points,以此达到通过下述随机数生成器生成的数恰好存在 p 。要求 points 不得低于 y ,且通过 AC 已经获得了 x points 。问最少的 successful hack 次数。
i := (s div 50) mod 475repeat 25 times: i := (i * 96 + 42) mod 475 print (26 + i)
解题思路
根据该随机数生成器可以知道初始 i 是 (s div 50) mod 475
得到的,即
由于要求 successful hack 次数最少,即该场 Round 分数应尽可能低,分数的可能性为
代码
#include<bits/stdc++.h>using namespace std;int p, x, y;bool jug(int s){ int i = s/50 % 475; for(int ica=0;ica<25;ica++) { i = (i*96 + 42) % 475; if(i+26 == p) return true; } return false;}int main(){ scanf("%d %d %d",&p,&x,&y); int X = x, ans = 0; while(X-50 >= y) X-=50; while(1) { if(jug(X)) { printf("%d\n", ans); return 0; } X += 50; if(X-x == 50) ans++, x+=100; }}
- Codeforces Round #412 B. T-Shirt Hunt
- Codeforces Round #412 B. 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
- codeforces T-Shirt Hunt(傻瓜暴力)
- CF#807 B. T-Shirt Hunt(水题)
- CodeForces 799B (B) T-shirt buying
- Codeforces 799B T-shirt buying 题解
- Codeforces Round #413 Div. 1 + Div. 2 B. T-shirt buying
- Codeforces Round #413 (Div.1 + Div. 2) B. T-shirt buying
- 使用Okhttp上传图片
- 对于大流量的网站,采用什么方法解决访问量问题
- android编译错误recipe commences before first target。 停止
- macOS使用 之 读写NTFS格式磁盘
- Spring3.1.0实现原理分析(七).填充Bean属性,初始化Bean,登记善后处理,注册单例Bean
- Codeforces Round #412 B. T-Shirt Hunt
- .Net MVCController 异步处理
- Mybatis对乐观锁的支持
- 一行代码解决各种IE兼容问题,IE6,IE7,IE8,IE9,IE10
- SpringMVC 传递相同名称的参数的最佳方法
- Angular4中常用管道
- RSA非对称 详细理解与使用
- React Native开发APP
- 安装cm初始脚本配置数据库scm_prepare_database.sh(在主节点上)遇到的问题