#13363: Why OLE?


10530826 (Starry Knight)

學校 : 臺北市立成功高級中學
編號 : 62083
來源 : [114.198.167.25]
最後登入時間 :
2020-11-14 10:15:59
c096. 00700 - Date Bugs -- UVa700 | From: [49.159.135.82] | 發表日期 : 2018-02-08 07:33

#include<iostream>
using namespace std;
int main()
{
int n,c=0;
while(cin>>n&&n!=0)
{
c++;
int y[20],a[20],b[20],ans;
bool match=false;
for(int i=0;i<n;i++)
cin>>y[i]>>a[i]>>b[i];
ans=y[0];
while(ans<10000)
{
bool t=true;
for(int i=1;i<n;i++)
{
int k=ans,d=b[i]-a[i];
if(k>=b[i])
k=(k-b[i])%d+a[i];
if(k!=y[i])
{
t=false;
break;
}
}
if(t)
{
match=true;
break;
}
ans+=(b[0]-a[0]);
}
cout<<"Case #"<<c<<":\n";
if(match)
cout<<"The actual year is "<<ans<<".\n\n";
else
cout<<"Unknown bugs detected.\n\n";
}
return 0;
}

 
ZeroJudge Forum