题目传送门
/*
题意:每支队伍需求打印机打印n张纸,当打印纸数累计到s时,打印机崩溃,打印出当前打印的纸数,s更新为(s*x+y)%mod
累计数清空为0,重新累计
模拟简单题:关键看懂题意
注意:打印机一张一张纸打印,当某支队伍打印完正好累计到s时,要输出0,坑点!
*/
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std;
int cnt[];
char ss[][];
int main(void) //J Contest Print Server
{
//freopen ("J.txt", "r", stdin);
int t;
while (scanf ("%d", &t) == )
{
while (t--)
{
int n, s, x, y, mod;
scanf ("%d%d%d%d%d", &n, &s, &x, &y, &mod);
for (int i=; i<=n; ++i)
scanf ("%s request %d pages", &ss[i], &cnt[i]);
int num = , j;
int ok = ;
for (int i=; i<=n; ++i)
{
if (ok == ) printf ("%d pages for %s\n", , ss[i]);
ok = ;
for (j=; j<=cnt[i]; ++j)
{
num++;
if (num == s)
{
printf ("%d pages for %s\n", j, ss[i]);
s = (s * x + y) % mod;
if (s == ) s = (s * x + y) % mod;
num = ; break;
}
}
if (j < cnt[i]) i--;
else if (j == cnt[i]) ok = ;
else printf ("%d pages for %s\n", cnt[i], ss[i]);
}
if (t) puts ("");
}
}
return ;
}
/*
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
*/