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

    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.

    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

    题目大义:有一台打印机,每隔s张都会清空计数器并重新打印。

    简单代码:

    #include<iostream>
    using namespace std;
    int main()
    {
        int c;
        cin>>c;
        while(c--)
        {
            int n,s,x,y,mod;
            cin>>n>>s>>x>>y>>mod;
            string name,re,pa;
            int fl;
            int cot=0;
            while(n--)
            {
                cin>>name>>re>>fl>>pa;
                //cout<<fl<<endl;
    
                if(cot+fl<=s)
                {
                    cout<<fl<<" pages for "<<name<<endl;
                    cot+=fl;
                }
                else
                {
                        cout<<s-cot<<" pages for "<<name<<endl;
                        int n = cot;
                        s=(s*x+y)%mod;
                        cot =0;
                        while(fl>s){
                                cout<<s<<" pages for "<<name<<endl;
                                cot=0;
                                s=(s*x+y)%mod;
                            }
                        cout<<fl<<" pages for "<<name<<endl;
                        cot+=fl;
                }
            }
            cout<<endl;
        }
    }
  • 相关阅读:
    超强视频分割/剪辑软件:Ultra Video Splitter绿色便携版
    PAZU 4Fang WEB 打印控件
    PHP开源网站
    jQuery实现点击小图显示大图效果
    博观而约取,厚积而薄发
    jquery两边飘浮的对联广告
    图片或文字循环滚动JS代码收集
    降低站长成本 推荐8个免费或低廉小型建站工具
    市净率
    浅谈策略交易、系统交易和程式交易
  • 原文地址:https://www.cnblogs.com/upstart/p/6793019.html
Copyright © 2011-2022 走看看