天天看點

step1_入門_ACM基礎訓練 18歲生日

18歲生日

http://acm.hdu.edu.cn/showproblem.php?pid=1201

//注意變量問題

//1、循環内循環的變量是不是常數,而實際上是i

//2、n和m搞混

//3、變量名重複定義

//注意變量問題
//1、循環内循環的變量是不是常數,而實際上是i 
//2、n和m搞混 
//3、變量名重複定義 


#include<iostream>
#include<set>
#include<cstdio>
using namespace std;
bool r(int y){
	return (y%4==0&&y%100!=0)||y%400==0;
}
int main(){
	int T;cin>>T;
	while(T--){
		int y,m,d;
		scanf("%d-%d-%d",&y,&m,&d);
		if(m==2&&d==29){
			if(!r(y+18)){
				cout<<-1<<endl;
				continue;
			}
		}
		int num=0;
		if(m<=2){	
			for(int i=y;i<y+18;i++){
				if(r(i))num+=366; 
				else num+=365; 
			} 
		}else{
			for(int i=y+1;i<=y+18;i++){
				if(r(i))num+=366;
				else num+=365; 
			} 
		}
		cout<<num<<endl;
		
		
	}
	return 0;
}