为什么我连输入都会挂???

P1167 刷题

Zhoulijie @ 2019-10-03 14:53:14

为什么我连输入都会挂???

#include <bits/stdc++.h>
using namespace  std;
bool test(int y){
    if((y%4==0&&y%100!=0)||y%400) return true;
    else return false;
}
int main(){
    freopen("1167.in","r",stdin);
    int n;
    char inp[20];

    cin>>n;
    int t[5010];
    for (int i = 0; i < n; ++i)
    {
        cin>>t[i];
        /* code */
    }
    int count;
    long y1,m1,d1,h1,mi1,y2,m2,d2,h2,mi2;
//  scanf("%d-%d-%d-%d:%d",&y1,&m1,&d1,&h1,&m1);
//  scanf("%d-%d-%d-%d:%d",&y2,&m2,&d2,&h2,&m2);
//  printf("%d-%d-%d-%d:%d\n",y1,m1,d1,h1,m1);
//  printf("%d-%d-%d-%d:%d\n",y2,m2,d2,h2,m2);
    for (int i = 0; i <= 15; ++i)
    {
        cin>>input[i];
        /* code */
    }
    y1=input[0]*1000+input[1]*100+input[2]*10+input[3];
    m1=input[5]*10+input[6];
    d1=input[8]*10+input[9];
    t1=input[11]*10+input[12];
    mi1=input[14]*10+input[15]; 
    for (int i = 0; i <= 15; ++i)
    {
        cin>>input[i];
        /* code */
    }
    y2=input[0]*1000+input[1]*100+input[2]*10+input[3];
    m2=input[5]*10+input[6];
    d2=input[8]*10+input[9];
    t2=input[11]*10+input[12];
    mi2=input[14]*10+input[15];
    for (int i = 0; i < y2-y1 ; ++i)
    {
        if (test(y1+i))
        {
            count++;
            /* code */
        }
        /* code */
    }
    unsigned long long sec=0,temp1=0;
    temp1=((y2-y1)*365+count)*86400+(h2-h1+1)*3600+(mi2-mi1+1)*60;
    sec=temp1;
    count=0;
    for (int i = 0; i < n; ++i)
    {
        if (sec>=t[i])
        {
            sec-=t[i];
            count++;
            /* code */
        }
        else break;
        /* code */
    }
    cout<<count<<endl;
    return 0;
}

by Zhoulijie @ 2019-10-03 14:53:34

求助大佬们


by All_Might @ 2019-10-03 14:53:50

freopen?


by Sakura_Zero @ 2019-10-04 22:27:08

freopen


by Suuon_Kanderu @ 2020-01-09 20:31:55

freopen


|