#include<iostream> #include<string> using namespace std; const int days[3] = { 28, 30, 31}; const int dcount[3] = { 1, 4, 7 }; const int year = 365; int getCount(char c) { int num = c - '0'; int deniedDayCount = 0, temp = 0; int target1 = (num + 9) % 10; int target2 = (num + 1) % 10; for (int i = 0; i < 3; ++i) { if (target1 != 0)temp++; if (target2 != 0)temp++; for (int j = 10; j <= 30; j += 10) { if (target1 + j <= days[i])temp++; if (target2 + j <= days[i])temp++; } deniedDayCount += temp * dcount[i]; temp = 0; } return year - deniedDayCount; } int main() { int n; string s; cin >> n; for (int i = 0; i < n; i++) { cin >> s; cout << getCount(*(s.end() - 1)) << endl; } return 0; } |
Double click to view unformatted code.