码迷,mamicode.com
首页 > 其他好文 > 详细

1058 A+B in Hogwarts (20 分)

时间:2019-02-24 10:53:03      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:desc   order   spec   vector   HERE   leo   lld   open   ace   

1058 A+B in Hogwarts (20 分)

If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it‘s easy enough." Your job is to write a program to compute A+B where A and B are given in the standard form of Galleon.Sickle.Knut(Galleon is an integer in [0,10?7??], Sickle is an integer in [0, 17), and Knut is an integer in [0, 29)).

Input Specification:

Each input file contains one test case which occupies a line with A and B in the standard form, separated by one space.

Output Specification:

For each test case you should output the sum of A and B in one line, with the same format as the input.

Sample Input:

3.2.1 10.16.27

Sample Output:

14.1.28


分析:水题,注意可能溢出,用long long保险点
 1 /**
 2 * Copyright(c)
 3 * All rights reserved.
 4 * Author : Mered1th
 5 * Date : 2019-02-24-01.29.25
 6 * Description : A1058
 7 */
 8 #include<cstdio>
 9 #include<cstring>
10 #include<iostream>
11 #include<cmath>
12 #include<algorithm>
13 #include<string>
14 #include<unordered_set>
15 #include<map>
16 #include<vector>
17 #include<set>
18 using namespace std;
19 
20 int main(){
21 #ifdef ONLINE_JUDGE
22 #else
23     freopen("1.txt", "r", stdin);
24 #endif
25     int b,c;
26     int e,f;
27     int h=0,i=0;
28     long long a,d,g=0;
29     scanf("%lld.%d.%d %lld.%d.%d",&a,&b,&c,&d,&e,&f);
30     i=f+c;
31     if(i>=29){
32         i-=29;
33         h++;
34     }
35     h=h+b+e;
36     if(h>=17){
37         h-=17;
38         g++;
39     }
40     g=g+a+d;
41     printf("%lld.%d.%d",g,h,i);
42     return 0;
43 }

 




1058 A+B in Hogwarts (20 分)

标签:desc   order   spec   vector   HERE   leo   lld   open   ace   

原文地址:https://www.cnblogs.com/Mered1th/p/10425179.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!