Bnuoj 17286 dollars

Source: Internet
Author: User
Dollarstime limit: 3000 msmemory limit: 131072 kbthis problem will be judged on ultraviolet A. Original ID: 147
64-bit integer Io format: % LLD Java class name: Main

New Zealand currency consists of $100, $50, $20, $10, and $5 notes and $2, $1, 50C, 20C, 10c and 5C coins. write a program that will determine, for any given amount, in how many ways that amount may be made up. changing the order of listing does not increase the count. thus 20c may be made up in 4 ways: 1 20C, 2 10C, 10C + 2 5C, and 4 5C.

 

Input

Input will consist of a series of real numbers no greater than $300.00 each on a separate line. each amount will be valid, that is will be a multiple of 5C. the file will be terminated by a line containing zero (0.00 ).

 

Output

Output will consist of a line for each of the amounts in the input, each line consisting of the amount of money (with two decimal places and right justified in a field of width 6 ), followed by the number of ways in which that amount may be made up, right justified in a field of width 17.

 

Sample Input

 

0.202.000.00

 

Sample output

 

0.20 4 2.00 293


Problem solving: several pitfalls. First, use long, but enter 0 to terminate the program.

 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <climits> 7 #include <vector> 8 #include <queue> 9 #include <cstdlib>10 #include <string>11 #include <set>12 #include <stack>13 #define LL long long14 #define pii pair<int,int>15 #define INF 0x3f3f3f3f16 using namespace std;17 int c[] = {5,10,20,50,100,200,500,1000,2000,5000,10000};18 LL dp[30010];19 int main() {20     int val = 30000;21     double ans;22     memset(dp,0,sizeof(dp));23     dp[0] = 1;24     for(int i = 0; i < 11; i++){25             for(int j = c[i]; j <= val; j++){26                 dp[j] += dp[j-c[i]];27             }28         }29     while(~scanf("%lf",&ans) && ans != 0.00 ){30         printf("%6.2f%17lld\n",ans,dp[int(ans*100+0.5)]);31     }32     return 0;33 }
View code

 

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.