【恢复状态】第三届山东省ACM竞赛Problem J——Contest Print Server

回来回复一下状态,当时比赛的时候并没有注意0的情况,注意了这个之后可以模拟过:

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

class teamnode
{
    char name[30];
    int num;
};
teamnode team[105];

int main()
{
    int t,n,s,x,y,mod,i,j,cnt;
    cin>>t;
    while(t--)
    {
        scanf("%d%d%d%d%d",&n,&s,&x,&y,&mod);
        for(i = 1; i<=n; i++)
            scanf("%s request %d pages",team[i].name,&team[i].num);
            cnt = s;
        for(i = 1; i<=n; i++)
        {
            while(1)
            {
                if(team[i].num<=cnt)
                {
                    printf("%d pages for %s\n",team[i].num,team[i].name);
                    cnt-=team[i].num;
                    break;
                }
                else
                {
                    printf("%d pages for %s\n",cnt,team[i].name);
                    s = (s*x+y)%mod;
                    if(s==0)
                        s = (s*x+y)%mod;
                        cnt = s;
                }
            }
        }
        printf("\n");
    }

    return 0;
}


你可能感兴趣的:(【恢复状态】第三届山东省ACM竞赛Problem J——Contest Print Server)