If you are a Harry Potter fan, you will know that the Wizarding world has its own monetary system-as Hagrid told Harry: "17 Silver Sickle (Galleon), 29 Nat (Knut) against a west, is easy." "Now, given the price Harry has to deal with and the money he pays a, your task is to write a program to calculate the change he should be looking for."
Input format:
The input gives p and a in 1 rows, in the form "Galleon.Sickle.Knut", separated by 1 spaces. Here galleon is an integer in the [0, 107] interval, sickle is an integer within the interval of [0, 17), and Knut is an integer within the [0, 29] interval.
Output format:
Output the change Harry should be looking for in a row with the same format as the input. If he does not have enough money, then the output should be negative.
Input Sample 1:
10.16.27 14.1.28
Output Example 1:
3.2.1
Input Sample 2:
14.1.28 10.16.27
Output Example 2:
-3.2.1
are converted to the smallest units, and then converted to the corresponding units.
But when the money is not enough, first the minus, then the positive number of operation
#include <bits/stdc++.h>#defineLL Long Long#defineMAXN 100+50#defineTIME1 29#defineTIME2 17using namespacestd;intpay[3], act[3];intMain () {scanf ("%d.%d.%d%d.%d.%d", &pay[0], &pay[1], &pay[2], &act[0], &act[1], &act[2]); pay[2] + = pay[0]*time1*TIME2; pay[0] =0; pay[2] + = pay[1]*TIME1; pay[1] =0; act[2] + = act[0]*time1*TIME2; act[0] =0; act[2] + = act[1]*TIME1; act[1] =0; intres = act[2]-pay[2]; if(res<0) {printf ("-"); Res= -Res; } printf ("%d.%d.%d", Res/time1/time2, Res/time1%time2, res%TIME1); return 0;}
Capouis ' CODE
pat-basic-1037-for change at Hogwarts.