View Code of Problem 8

#include<bits/stdc++.h>
using namespace std;
int main() {
	int day[12]={31,28,31,30,31,30,31,31,30,31,30,31}, N;
	vector<int> count(10,365);
	for(int i=0; i<=9; i++) {//尾号 
		for(int d=0; d<12; d++) {//月份 
			for(int j=1; j<=day[d]; j++) {//天 
				if((j+1)%10==i||(j-1)%10==i) count[i]--;
			}
		}
	}
	cin>>N;
	string s;
	while(N--) {
		cin>>s;
		cout<<count[s[s.length()-1]-'0']<<endl;
	}
}

Double click to view unformatted code.


Back to problem 8