View Code of Problem 8

#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int main(){
	//freopen("8.txt","r",stdin);
	int n;
	int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int cnt[10]={0};
	for(int i=0;i<10;i++){
		int sum=0;
		for(int j=0;j<12;j++){
			for(int k=1;k<=month[j];k++){
				if(i==(k-1)%10||i==(k+1)%10)	sum++;
			}
		}
		cnt[i]=365-sum;
	}
	string str;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin>>str;
		int len=str.length();
		int ans=str[7]-'0';
		printf("%d\n",cnt[ans]);
	}
}

Double click to view unformatted code.


Back to problem 8