poj_1006

Problem: http://poj.grids.cn/problem?id=1006
Solution:
 

#include
#include
#include
using namespace std;
int main()
{
    int p, e, i, n=0;
    long cp, ce, ci;
    short d;
    int j=1;//计数用
    ostringstream buf;
    while(1)
    {
        cin>>p>>e>>i>>d;
        if(p==-1 && e==-1 && i==-1 && d==-1)
        {
            break;
        }
        n=d;
        while(1)
        {
            n++;
            if((n-p)%23==0 && (n-e)%28==0 && (n-i)%33==0)
            {
                n-=d;
                if(n==0)
                {
                    n=d;
                    continue;
                }
                break;
            }
            //cout< <"*";
        }
        buf<<"Case "<


Posted

in

by

Tags:

Comments

Leave a Reply

%d bloggers like this: