zoukankan      html  css  js  c++  java
  • POJ 1044: Date bugs

    #include <iostream>
    #include <string>
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <deque>
    #include <map>
    #define range(i,a,b) for(int i=a;i<=b;++i)
    #define LL long long
    #define rerange(i,a,b) for(int i=a;i>=b;--i)
    #define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
    using namespace std;
    int y[20],a[20],t[20],n,cas;
    void init(){
    
    }
    void solve(){
        while(cin>>n,n){
            range(i,0,n-1){
                cin>>y[i]>>a[i]>>t[i];
                t[i]-=a[i];
            }
            int ans=0;
            while((a[0]=y[0]+ans*t[0])<10000){
                bool flag=true;
                range(i,1,n-1){
                    int tmp=a[0]-y[i];
                    if(tmp<0||tmp%t[i]){
                        flag=false;
                        break;
                    }
                }
                if(flag){
                    cout<<"Case #"<<++cas<<":"<<endl;
                    cout<<"The actual year is "<<a[0]<<"."<<endl<<endl;
                    break;
                }
                ++ans;
            }
            if(a[0]>=10000){
                cout<<"Case #"<<++cas<<":"<<endl;
                cout<<"Unknown bugs detected."<<endl<<endl;
            }
        }
    }
    int main() {
        init();
        solve();
        return 0;
    }
    View Code
  • 相关阅读:
    3月14日进度博客
    构建之法阅读笔记01
    课堂练习-全国疫情统计3
    课堂练习-全球疫情统计2
    课堂练习-全国疫情统计1
    跟我一起写 Makefile(五)
    跟我一起写 Makefile(四)
    跟我一起写 Makefile(三)
    跟我一起写 Makefile(二)
    跟我一起写 Makefile(一)
  • 原文地址:https://www.cnblogs.com/Rhythm-/p/9339138.html
Copyright © 2011-2022 走看看