pat-basic-1037-for change at Hogwarts.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.