본문 바로가기
4_ 고소한 알고리즘

C- ACM - Coin

by 준환이형님_ 2010. 6. 8.

으음.. 막상 이해하고 나면 /이게 뭐야/ 할지도 ㅋㅋ

In Korea, there are four kinds of coins – a 10-won coin, a 50-won coin, 100-won coin and a 500-won coin.
Given K 10-won coins, L 50-won coins, M 100-won coins and N 500-won coins, you are to write a program that calculate the total amount.
Input
The input consists of T test cases. The number of test cases T is given in the first line of the input file. Each test case will consist of four integers K, L, M and N (0<K, L, M, N>100). The integers given in a line are separated by a space.
Output
Print exactly one line for each test case. For each test case of K, L, M and N you should output the total amount.
The following shows sample input and output for three test cases.
Sample Input
Output for the Sample Input
3
1 1 1 1
answer : 660
0 1 2 3
answer : 1750
1 2 10 20
answer : 11110

#include <stdio.h>
int main(void)
{
 int repeat=NULL;
 int K,L,M,N; 
 scanf("%d",&repeat);
 for(int i=0; i<repeat; i++)
 {
  scanf("%d %d %d %d",&K, &L, &M, &N);
  printf("%d\n",K*10+L*50+M*100+N*500);
 }
 return 0;
}

'4_ 고소한 알고리즘' 카테고리의 다른 글

C- ACM - 지뢰찾기  (4) 2010.06.23
C- ACM - 수 뒤집기  (0) 2010.06.12
C- ACM - 소수판정  (0) 2010.06.09
C- ACM - 문자열  (0) 2010.06.08
C- ACM - 더하기  (0) 2010.06.07