ITKeyword,专注技术干货聚合推荐

注册 | 登录

山东省第四届ACM大学生程序设计竞赛-Contest Print Server(模拟)

分享于 2016-04-12

推荐:山东省第四届ACM大学生程序设计竞赛-Boring Counting(划分树-二分查找)

Boring Counting Time Limit: 3000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述     In this problem you are given a number sequence P consisting

2018阿里云全部产品优惠券(新购或升级都可以使用,强烈推荐)
领取地址https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=82lei0yp

Contest Print Server

Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描述

    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.

输入

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.

输出

    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.

示例输入

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

示例输出

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

提示

 

来源

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


题意:

求每个队打印的纸的张数。

推荐:[2012山东省第三届ACM大学生程序设计竞赛]——The Best Seat in ACM Contest

The Best Seat in ACM Contest 题目:http://acm.sdut.edu.cn/sdutoj/problem.phpaction=showproblem&problemid=2409 Time Limit: 1000ms Memory limit: 65536K

当纸不够的时候先输出剩下够打印多少张,再重新输出这个队一共要打印多少张。

注意前一个对刚好使用完额度的时候,下一个队先输出0张。

注意就算当前置零,p依然可能超过s,所以要重判!!!

一开始是s,当超过s时s变为s=(s*x+y)%mod;


/*
* Copyright (c) 2016, 烟台大学计算机与控制工程学院
* All rights reserved.
* 文件名称:print.cpp
* 作    者:单昕昕
* 完成日期:2016年4月12日
* 版 本 号:v1.0
*/
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <stdlib.h>
using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,s,x,y,mod,cnt=0,flag=0;
        scanf("%d%d%d%d%d",&n,&s,&x,&y,&mod);
        while(n--)
        {
            char s1[20],s2[10],s3[10];
            int p;
            scanf("%s%s%d%s",s1,s2,&p,s3);
A:
            cnt+=p;
            if(cnt<=s)
                printf("%d pages for %s\n",p,s1);
            else
            {
                cnt-=p;
                printf("%d pages for %s\n",s-cnt,s1);
                s=(s*x+y)%mod;
                cnt=0;//此时当前的p依然有可能超过s所以要goto重判
                goto A;
            }
        }
        cout<<endl;
    }
    return 0;
}


推荐:山东省第七届ACM大学生程序设计竞赛-Execution of Paladin(炉石传说-模拟)

Execution of Paladin Time Limit: 2000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Murloc is a powerful race in Hearthstone. In the set League

Contest Print Server Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述     In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your sourc

相关阅读排行


用户评论

游客

相关内容推荐

阿里云RDS

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。