#include<stdio.h> #include<string.h> int main() { int T, i, j, x, num, num1; char a[100]; scanf("%d", &T); for (i = 0; i < T; i++) { num = 0; num1 = 0; scanf("%s", a); x = a[strlen(a) - 1] - '0'; if (x == 0) { printf("287\n"); } if (x == 9) { printf("294\n"); } if(x!=9&&x!=0) { for (j = 1; j <= 31; j++) { if (j % 10 - 1 == x || j % 10 + 1 == x) { num++; } } num = num * 7; for (j = 1; j <= 28; j++) { if (j % 10 - 1 == x || j % 10 + 1 == x) { num++; } } for (j = 1; j <= 30; j++) { if (j % 10 - 1 == x || j % 10 + 1 == x) { num1++; } } num1 = num1 * 4; num = num + num1; printf("%d\n", 365 - num); } } } |
Double click to view unformatted code.