PersonalCorpus 版 (精华区)

40964 2002-10-12 13:07:27 Accepted
1143 C++ 00:00.00 380K Big Guava

int main()
{
#ifndef ONLINE_JUDGE
    freopen("c:\\0acm\\uva\\input700.txt","r",stdin);
    freopen("c:\\0acm\\uva\\output700.txt","w",stdout);
#endif

    int a[20],b[20],y[20];
    int i,j,k,n,tot=0;
    bool ok;

    scanf("%d\n",&n);
    while (n>0) {
        tot++;
        printf("Case #%d:\n",tot);
        j=0;
        for (i=0;i<n;i++) {
            scanf("%d%d%d\n",&y[i],&a[i],&b[i]);
            if (a[i]>j) j=a[i];
            y[i]=(y[i]-a[i])%(b[i]-a[i]);
        }
        ok=false;
        for (i=j;i<10000;i++) {
            ok=true;
            for (k=0;k<n;k++) if ((i-a[k])%(b[k]-a[k])!=y[k]) {
                ok=false;
                break;
            }
            if (ok) break;
        }
        if (i<10000)
            printf("The actual year is %d.\n\n",i);
          else
            printf("Unknown bugs detected.\n\n");
        scanf("%d\n",&n);
    }
}
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.127毫秒