• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Warm up 17 A Millennium

Millennium
Time Limit: 30000ms, Special Time Limit:75000ms, Memory Limit:262144KB
Total submit users: 7, Accepted users: 7
Problem 12787 : No special judgement
Problem description

A wise king declared a new calendar. "Tomorrow shall be the first day of the calendar, that is, the day 1 of the month 1 of the year 1.  Each year consists of 10 months, from month 1 through month 10, and starts from a big month.  A common year shall start with a big month, followed by small months and big months one after another.  Therefore the first month is a big month, the second month is a small month, the third a big month, ..., and the 10th and last month a small one.  A big month consists of 20 days and a small month consists of 19 days.  However years which are multiples of three, that are year 3, year 6, year 9, and so on, shall consist of 10 big months and no small month."

Many years have passed since the calendar started to be used.  For celebration of the millennium day (the year 1000, month 1, day 1), a royal lottery is going to be organized to send gifts to those who have lived as many days as the number chosen by the lottery.  Write a program that helps people calculate the number of days since their birthdate to the millennium day.

Input

The input is formatted as follows.

n Y1 M1 D1 Y2 M2 D2     ... Yn Mn Dn

Here, the first line gives the number of datasets as a positive integer n, which is less than or equal to 100.  It is followed by n datasets.  Each dataset is formatted in a line and gives three positive integers, Yi (< 1000), Mi (≤ 10), and Di (≤ 20), that correspond to the year, month and day, respectively, of a person's birthdate in the king's calendar.  These three numbers are separated by a space.

Output

For the birthdate specified in each dataset, print in a line the number of days from the birthdate, inclusive, to the millennium day, exclusive.  Output lines should not contain any character other than this number.

Sample Input
8
1 1 1
344 3 1
696 5 1
182 9 5
998 8 7
344 2 19
696 4 19
999 10 20

Sample Output
196470
128976
59710
160715
252
128977
59712
1

Submit   Clarifications   Judge Status  Problems  Ranklist 
 1 #pragma comment(linker, "/STACK:1024000000,1024000000")
 2 #include <map>
 3 #include <stack>
 4 #include <queue>
 5 #include <vector>
 6 #include <string>
 7 #include <cmath>
 8 #include <cstdio>
 9 #include <cstring>
10 #include <cstdlib>
11 #include <iostream>
12 #include <algorithm>
13 using namespace std;
14 #define maxn 10055
15 #define ll long long
16 #define mod 1000000007
17 #define INF 0x7fffffff
18 #define eps 1e-8
19 int n, m, k, sx, sy;
20 int a[maxn];
21 int main(){
22     int t;
23     scanf("%d", &t);
24     while (t--){
25     //memset(a, 0, sizeof a);
26     //memset(b, 0, sizeof b);
27         scanf("%d%d%d", &n, &m,&k);
28         int s = 0;
29         for (int i = n + 1; i < 1000; i++)
30             if (i % 3 == 0)s += 200;
31             else s += 195;
32         for (int i = m + 1; i <= 10; i++)
33             if (n % 3 != 0){
34                 if (i & 1)s += 20;
35                 else s += 19;
36             }
37             else s += 20;
38         for (int i = k+1 ;; i++){
39             s++;
40             if (n % 3 == 0){
41                 if (i > 20)break;
42             }
43             else if (m & 1){if (i > 20)break;}
44             else if (i > 19)break;
45         }
46         printf("%d\n", s);
47     }
48     return 0;
49 }
View Code
posted @ 2013-11-11 15:26  HaibaraAi  阅读(167)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3