zoukankan      html  css  js  c++  java
  • 模拟 2013年山东省赛 J Contest Print Server

    题目传送门

     1 /*
     2     题意:每支队伍需求打印机打印n张纸,当打印纸数累计到s时,打印机崩溃,打印出当前打印的纸数,s更新为(s*x+y)%mod
     3             累计数清空为0,重新累计
     4     模拟简单题:关键看懂题意
     5     注意:打印机一张一张纸打印,当某支队伍打印完正好累计到s时,要输出0,坑点!
     6 */
     7 #include <cstdio>
     8 #include <cmath>
     9 #include <algorithm>
    10 #include <iostream>
    11 #include <cstring>
    12 using namespace std;
    13 
    14 int cnt[110];
    15 char ss[110][22];
    16 
    17 int main(void)        //J Contest Print Server
    18 {
    19     //freopen ("J.txt", "r", stdin);
    20     
    21     int t;
    22     while (scanf ("%d", &t) == 1)
    23     {
    24         while (t--)
    25         {
    26             int n, s, x, y, mod;
    27             scanf ("%d%d%d%d%d", &n, &s, &x, &y, &mod);
    28             
    29             for (int i=1; i<=n; ++i)
    30                 scanf ("%s request %d pages", &ss[i], &cnt[i]);
    31 
    32             int num = 0, j;
    33             int ok = 0;
    34             for (int i=1; i<=n; ++i)
    35             {
    36                 if (ok == 1)    printf ("%d pages for %s
    ", 0, ss[i]);
    37                 ok = 0;
    38                 for (j=1; j<=cnt[i]; ++j)
    39                 {
    40                     num++;
    41                     if (num == s)
    42                     {
    43                         printf ("%d pages for %s
    ", j, ss[i]);
    44                         s = (s * x + y) % mod;
    45                         if (s == 0)    s = (s * x + y) % mod;
    46                         num = 0;    break;
    47                     }
    48                 }
    49                 if (j < cnt[i])    i--;
    50                 else if (j == cnt[i])    ok = 1;
    51                 else    printf ("%d pages for %s
    ", cnt[i], ss[i]);
    52             }
    53             if (t)    puts ("");
    54         }
    55         
    56     }
    57     
    58     
    59     return 0;
    60 }
    61 
    62 /*
    63 1 pages for Team1
    64 5 pages for Team2
    65 1 pages for Team3
    66 
    67 1 pages for Team1
    68 3 pages for Team2
    69 5 pages for Team2
    70 1 pages for Team3
    71 */
    编译人生,运行世界!
  • 相关阅读:
    XML解析
    异步网络请求和JOSN解析
    iOS iOS8新特性-UIAlertController
    iOS8新特性 UIPresentationController(一)
    iOS沙盒(sandbox)机制及获取沙盒路径
    iOS学习之iOS沙盒(sandbox)机制和文件操作(一)
    IOS沙盒机制(SandBox)
    手势(转)
    //快速添加一个视图控制器
    iOS开发常用的网站(转老师的)
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4398628.html
Copyright © 2011-2022 走看看