zoukankan      html  css  js  c++  java
  • Codeforces Round #412 B. T-Shirt Hunt

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

    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.

     
     
    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.

    题目大意:在不久的Codecraft-17比赛中,排名前25的参赛者以及在前500名内随机挑选的25名选手将会获得 印有“Codecraft-17”logo的 T-shirt

         不幸的是,有一小伙没能杀进前25,但是他在前500名内。他很想获得这次的T-shirt,so~ 他决定参加接下来的淘汰赛

         (淘汰赛的获胜者将会获得一件T-shirt)

         在淘汰赛中他将会通过hack来使得自己能够获胜并获得衣服。 hack胜利一次+100 失败一次-50

         现给定 排名、当前的分数、以及获胜所需的最小分数。分数跟题上的公式有关,可以产生一些排名

         这些名次的参赛者可以获得一件T-shirt。 输入他能够获胜并且获得一件T-shirt 最少需要hack成功几次

         (失败的hack不算入记录)

    解题思路:首先要保证x >= y ,然后进行失败的hack,判断是否成立。(失败的hack不算入记录)

         如果不成立的话,让分数上涨直至找到成立的情况。

         分数上涨包括两种情况:(1)hack成功 (2)hack成功之后再失败一次

    AC代码:

     1 #include <stdio.h>
     2 #include <string.h>
     3 #include <math.h>
     4 #include <stdlib.h>
     5 #include <algorithm>
     6 #define mod 475
     7 
     8 using namespace std;
     9 int p,x,y;
    10 bool f(int a)   // 判断名次p 是否会获得一件T-shirt
    11 {
    12     int i = (a/50)%mod;
    13     for (int j = 0; j < 25; j ++)
    14     {
    15         i = (i*96+42)%mod;
    16         if (i+26 == p)
    17             return true;
    18     }
    19     return false;
    20 }
    21 
    22 int main ()
    23 {
    24     int i,j,k,flag;
    25     while (scanf("%d %d %d",&p,&x,&y)!=EOF){
    26         flag = k = 0; j = x;
    27         while (j >= y){      // hack 失败
    28             if (f(j)){
    29                 printf("%d
    ",k); flag = 1; break;
    30             }
    31             j -= 50;
    32         }
    33         if (flag) continue;
    34 
    35         while (!f(x)){      
    36             x += 50;     // hack成功再失败一次
    37             k ++;
    38             if (f(x)){
    39                 printf("%d
    ",k); flag = 1; break;
    40             }
    41             x += 50;    // hack 成功
    42         }
    43         if (!flag)
    44             printf("%d
    ",k);
    45     }
    46     return 0;
    47 }

         

         

  • 相关阅读:
    Android HandlerThread
    JavaScript数据类型
    Android:VideoView
    我是如何跟踪log4j漏洞原理及发现绕WAF的tips
    Dubbo的反序列化安全问题——kryo和fst
    使用移动硬盘快速安装win7(附BIOS设置)
    OpenStack Swift All In One安装部署流程与简单使用
    C语言浮点数运算
    使用注册表文件(REG)添加、修改或删除Windows注册表项和值
    Linux之TCPIP内核参数优化
  • 原文地址:https://www.cnblogs.com/yoke/p/6833075.html
Copyright © 2011-2022 走看看