View Code of Problem 8

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main (){
	int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int n;
	scanf("%d", &n);
	while(n--){
		char str[15];
		scanf("%s", str);
		int a = str[strlen(str)-1]-'0';
		int cnt = 0;
		for(int i = 1;i <= 12;i++){
			for(int j = 1;j <= month[i];j++){
				if((j+1)%10==a||(j-1)%10==a) cnt++;
			}
		}
		printf("%d\n", 365-cnt);
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 8