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 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: Sample Output: |
#include <iostream>
#include<stdio.h>
using namespace std;
typedef long long ll;
const int l=29*17,r=29;
int main()
{
ll a,b,c,a1,b1,c1;
scanf("%lld.%lld.%lld %lld.%lld.%lld",&a,&b,&c,&a1,&b1,&c1);
ll ans=a*l+b*r+c;
ll sum=a1*l+b1*r+c1;
sum+=ans;
printf("%lld.%lld.%lld\n",sum/l,sum%l/r,sum%r);
return 0;
}