PersonalCorpus 版 (精华区)
Your C++ program has solved Ok the problem 700 (Date Bugs)
in 0.000 seconds with low memory spent.
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <math.h>
#include <ctype.h>
void 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.060毫秒