provlem link:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=280
solution code:
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int i,v,x,l,c,n,total,re,j;
while(cin>>n)
{
if(n==0)break;
i=v=x=l=c=0;
j=1;
while(j<=n)
{
re=j;
if(re>=100)
{
c+=re/100;
re=re%100;
}
if(re>=90)
{
c++;
x++;
re-=90;
}
if(re>=50)
{
l+=re/50;
re%=50;
}
if(re>=40)
{
l++;
x++;
re-=40;
}
if(re>=10)
{
x=x+re/10;
re%=10;
}
if(re>=9)
{
x++;
i++;
re-=9;
}
if(re>=5)
{
v+=re/5;
re%=5;
}
if(re>=4)
{
v++;
i++;
re-=4;
}
if(re>=1)
{
i=i+re;
}
j++;
}
printf("%d: %d i, %d v, %d x, %d l, %d c\n",n,i,v,x,l,c);
}
return 0;
}
0 comments:
একটি মন্তব্য পোস্ট করুন