Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:我不知道怎么提交不上!error answer 哪位高手帮我看一下啊?

Posted by wier at 2008-06-07 12:10:35
In Reply To:我不知道怎么提交不上!error answer 哪位高手帮我看一下啊? Posted by:youline at 2006-07-24 09:01:13
> 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 $50.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.20
> 2.00
> 0.00
> Sample output
>   0.20                4
>   2.00              293
> 下面是我写的代码,这是我的QQ263528853
> #include<iostream.h>
> #define Sum    4000    // 注意!!!不要改变这个数的值
> #define MaxCoinNo    10    // 所用的硬币数,最大为11个
> #define Value    1000        // *0.05即为面值
> #include <stdio.h>
> #include <malloc.h> 
> typedef float datatype; 
> typedef struct node 
> { 
> datatype data; 
> struct node *next; 
> }linklist; 
> linklist *p,*q,*head; 
> int main()
> {
>     int f[Value+Sum+1][MaxCoinNo];
>     int Coin[] = {1, 2, 4, 10, 20, 40, 100, 200, 400, 1000, 2000};
>     int i, j,w;
> 
> 	float l,money;
> 	head = (linklist *)malloc(sizeof(linklist)); 
> 	head->next = NULL; 
> 	p = head; 
> 	scanf("%f",&money); 
> //   printf("%f\n",money*100);
> 	while(money!=0.00) 
> 	{    
> 	l=money*100;w=int(l)%5;
>     if(w!=0||money>50.00||money<0.05) return 0;
>  	q = (linklist *)malloc(sizeof(linklist)); 
> 	q->data = money; 
> 	q->next = NULL; 
> 	p->next = q;
> 	p = p->next; 
> //l=money*100;w=int(l)%5;
> //  if(w!=0||money>50.00||money<0.05) return 0;
> 
> 	 
>   scanf("%f",&money);	} 
> 
> 
>     for(i = 0; i < Value + Sum; i++)
>         for(j = 0; j < MaxCoinNo; j++)
>         f[i][j] = 0;
>     for(j = 0; j < MaxCoinNo; j++)
>         f[Sum][j] = 1;
> 
>     p=head->next;
> //printf("%f",p->data);
> while(p!=NULL)
> {
> 
> //Intmoney=p->data/0.05;
> 	for(i = Sum + 1; i < Value + Sum + 1; i++)
>     {
>         f[i][0] = 1;
>         for(j = 1; j < MaxCoinNo; j++)
>             f[i][j] = f[i][j-1] + f[i - Coin[j]][j];
> 		if(i==(int)(20*(p->data+200)))
>  //       cout<<i*0.05 - 200<<":\t"<<f<<endl;
>  	
>  printf("%.2f     %7d\n",p->data,f[i][j-1]);
>    	}
> 	p=p->next;
> }
> }
> 
> 
> 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator