• 第四届 山东省ACM Contest Print Server


    Contest Print Server

    Time Limit: 1000MS Memory Limit: 65536KB

    Problem Description

        In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your source code any time. Here you need to write a contest print server to handle all the requests.

    Input

    In each case,the first line contains 5 integers n,s,x,y,mod (1<=n<=100, 1<=s,x,y,mod<=10007), and n lines of requests follow. The request is like "Team_Name request p pages" (p is integer, 0<p<=10007, the length of "Team_Name" is no longer than 20), means the team "Team_Name" need p pages to print, but for some un-know reason the printer will break down when the printed pages counter reached s(s is generated by the function s=(s*x+y)%mod ) and then the counter will become 0. In the same time the last request will be reprint from the very begin if it isn't complete yet(The data guaranteed that every request will be completed in some time).
        You can get more from the sample.

    Output

        Every time a request is completed or the printer is break down,you should output one line like "p pages for Team_Name",p is the number of pages you give the team "Team_Name".

        Please note that you should print an empty line after each case.

    Example Input

    23 7 5 6 177Team1 request 1 pagesTeam2 request 5 pagesTeam3 request 1 pages3 4 5 6 177Team1 request 1 pagesTeam2 request 5 pagesTeam3 request 1 pages

    Example Output

    1 pages for Team15 pages for Team21 pages for Team31 pages for Team13 pages for Team25 pages for Team21 pages for Team3

    Hint

     

    Author

     2013年山东省第四届ACM大学生程序设计竞赛



    #include <iostream>
    #include <algorithm>
    #include <stdio.h>
    using namespace std;
    typedef long long  ll;
    typedef unsigned long long ull;
    #define maxn 105
    
    int n,s,x,y,mod;
    struct str
    {
        char name[25];
        int p;
    };
    
    str tt[maxn];
    
    int main()
    {
        //read;
        int cas;
        scanf("%d",&cas);
        while(cas--)
        {
            scanf("%d%d%d%d%d",&n,&s,&x,&y,&mod);
            char s1[25],s2[25];
            for(int i=1; i<=n; ++i)
                scanf("%s%s%d%s",tt[i].name,s1,&tt[i].p,s2);
            int now=s;
            for(int i=1; i<=n; ++i)
            {
                if(tt[i].p<=now)
                {
                    printf("%d pages for %s
    ",tt[i].p,tt[i].name);
                    now-=tt[i].p;
                }
                else
                {
                    printf("%d pages for %s
    ",now,tt[i].name);
                    s=(x*s+y)%mod;
                    now=s;
                    --i;
                }
            }
            printf("
    ");
          }
        return 0;
    }
    





  • 相关阅读:
    腾讯会议API接入
    解决远程调用三方接口:javax.net.ssl.SSLHandshakeException报错
    iOS自动创建本地化文件
    数组转换
    2021MongoDB技术实践与应用案例征集活动获奖通知
    MongoDB按需物化视图介绍
    参会指南 | 2021MongoDB南京技术沙龙
    叮咚买菜自建MongoDB上云实践
    MongoDB技术实践与应用案例征集中
    使用WT工具恢复MongoDB数据
  • 原文地址:https://www.cnblogs.com/zswbky/p/6717888.html
Copyright © 2020-2023  润新知