14780 - Uniform Invoice Prize Calculation   

Description

(30 points)

A receipt number for the uniform invoice (統一發票) consists of 8 digits.
Each lottery period announces 3 special prize numbers and 3 first prize numbers.

Write a program to calculate the total amount of money you win based on your receipt numbers.

megapx

Prize Calculation Rules

  • If all 8 digits of your receipt number match any special prize number, you win 2,000,000 TWD.

  • If all 8 digits of your receipt number match any first prize number, you win 200,000 TWD.

  • If the last 7 digits of your receipt number match the last 7 digits of any first prize number, you win 40,000 TWD.

  • If the last 6 digits of your receipt number match the last 6 digits of any first prize number, you win 10,000 TWD.

  • If the last 5 digits of your receipt number match the last 5 digits of any first prize number, you win 4,000 TWD.

  • If the last 4 digits of your receipt number match the last 4 digits of any first prize number, you win 1,000 TWD.

  • If the last 3 digits of your receipt number match the last 3 digits of any first prize number, you win 200 TWD.

The program first reads three special prize numbers, followed by three first prize numbers.
After that, it reads multiple receipt numbers (each is 8 digits).
Your program must process all receipt numbers until end-of-file (EOF) and output the total prize amount.

while (scanf("%d", &input) != EOF) {...}

Input

  • The first 3 lines contain the special prize numbers.

  • The next 3 lines contain the first prize numbers.

  • The remaining lines contain receipt numbers collected by the user.

  • The input terminates at EOF.

Here is the explanation of sample input

Special Prize Numbers #1 55138690
Special Prize Numbers #2 14764045
Special Prize Numbers #3 41175733
First Prize Numbers #1 68787608
First Prize Numbers #2 77978931
First Prize Numbers #3 11071074
Your Receipt Numbers #1 12378931
Your Receipt Numbers #2 68787608

 

Number of your receipt is less than 500.

Output

Output a single integer representing the total prize amount won from all the receipts.

 

Here is the explanation of sample output

  • For Receipt #1, the last 5 digits match the last 5 digits of First Prize #2, so you win 4,000 TWD.

  • For Receipt #2, all 8 digits match First Prize #1, so you win 200,000 TWD.

Therefore, the total prize amount you win in this uniform invoice lottery is 204,000 TWD.

Ensure that the output, including formatting 輸出格式, exactly matches the provided samples.

Sample Input  Download

Sample Output  Download

Tags




Discuss