Saturday 21 March 2009

POJ ( acm.pku.edu.cn ) 3085

水题,贪心,我喜欢



#include <iostream>
using namespace std;
int main(){
int N;cin>>N;
for(int i=1;i<=N;++i){
int cents,q=0,d=0,n=0,p=0;
cin>>cents;
for(;cents-25>=0;cents-=25) ++q;
for(;cents-10>=0;cents-=10) ++d;
for(;cents- 5>=0;cents-= 5) ++n;
for(;cents>0; --cents ) ++p;
cout<<i<<' '
<<q<<" QUARTER(S), "<<d<<" DIME(S), "
<<n<<" NICKEL(S), "<<p<<" PENNY(S)"
<<endl;
}
return 0;
}

No comments:

Post a Comment