zoukankan      html  css  js  c++  java
  • Contest Print Server

    Contest Print Server
    Time Limit: 1000 MS Memory Limit: 32768 K
    Total Submit: 111(26 users) Total Accepted: 35(25 users) Rating: Special Judge: No
    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 the first line there is an integer T(T<=10),which indicates the number of test cases.

    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".

    Sample Input
    2
    3 7 5 6 177
    Team1 request 1 pages
    Team2 request 5 pages
    Team3 request 1 pages
    3 4 5 6 177
    Team1 request 1 pages
    Team2 request 5 pages
    Team3 request 1 pages
    Sample Output
    1 pages for Team1
    5 pages for Team2
    1 pages for Team3
    1 pages for Team1
    3 pages for Team2
    5 pages for Team2
    1 pages for Team3
    Source
    HCPC2014校赛训练赛 2

     题目大意是有一只很奇葩的打印机,只要纸张不够了,就得在没打印完的这个队伍重新开始

    #include<iostream>
    #include<cmath>
    #include<stdio.h>
    #include<algorithm>
    using namespace std;
    int n,s,x,y,mod;
    struct node
    {
        char a[30];
        int sum;
    }b[100];
    int main()
    {
        int T;
        while(~scanf("%d",&T))
        {
            while(T--)
            {
                scanf("%d%d%d%d%d",&n,&s,&x,&y,&mod);
                int i;
                char p[20];
                getchar();
                for(i=0;i<n;i++)
                {
                    scanf("%s%s%d%s",b[i].a,p,&b[i].sum,p);
                //    printf("%s%s%d%s",b[i].a,p,b[i].sum,p);
                }
                int h=s;
                for(i=0;i<n;i++)
                {
                    while(b[i].sum>h)
                    {
                        printf("%d %s %s %s
    ",h,"pages","for",b[i].a);
                        s=(s*x+y)%mod;
                        h=s;
                    }
                    h-=b[i].sum;
                    printf("%d %s %s %s
    ",b[i].sum,"pages","for",b[i].a);
                }
                printf("
    ");
            }
        }
        return 0;
    }
  • 相关阅读:
    MySQL-3(练习题)-三套知识点看完SQL没问题
    MySQL知识点-2(超详细)
    MySQL知识点-1(超详细)
    MySQL表结构笔记9
    MySQL增删改查&数据类型笔记8
    07:表联结MySQL笔记7
    spring事务传播机制
    MySQL查看两个查询的差集
    python连接数据库
    chrome一款可以在浏览器编辑hosts文件的插件HostAdmin App
  • 原文地址:https://www.cnblogs.com/beige1315402725/p/4905551.html
Copyright © 2011-2022 走看看