14 Mar 2013

Money Transformation_solved


/*

CODECHEF
PROBLEM CODE : MONTRANS
*/

#include<stdio.h>
 
int T,a,b,c;
void solve()
{
    int step=0,cnt=0;
    int m=a*100+b;
    while((a>0||b>=c)&&cnt<10000){
        cnt++;
        if(b<c)a--,b+=100;
        b-=c;
        int tmp=a;a=b;b=tmp;
        int t=a*100+b;
        if(t>m)m=t,step=cnt;
    }
    printf("%d\n",step);
}
int main()
{
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d",&a,&b,&c);
        solve();
    }
    return 0;
}
        

Categories: , , ,

0 comments:

Post a Comment

Copyright © UPgradeCODING | Powered by Blogger