|
|
back to boardWA1 ??? Posted by Hi4ko 2 Dec 2011 20:42 why is it so? #include <iostream> #include <cmath> using namespace std; int main() { int value[]={ 10, 50, 100, 500, 1000, 5000 }; int num[5],sum=0; int price; for(int i=0;i<6;i++) { cin>>num[i]; sum+=num[i]*value[i]; } cin>>price; int i=0; while(num[i]==0) ++i; int lol=0,lol1=0; while(lol*price<=sum-value[i]) ++lol; int j=0; int k=0; while((lol+k)*price<=sum) { ++lol1; ++k; } cout<<lol1<<endl; while((lol+j)*price<=sum) { cout<<lol+j<<" "; ++j; } } Re: WA1 ??? #include <iostream> #include <cmath> using namespace std; int main() { int value[]={ 10, 50, 100, 500, 1000, 5000 }; int num[5],sum=0; int price; for(int i=0;i<6;i++) { cin>>num[i]; sum+=num[i]*value[i]; } cin>>price; int i=0; while(num[i]==0) ++i; int lol=0,lol1=0; while(lol*price<=sum-value[i]) ++lol; int j=0; int k=0; while((lol+k)*price<=sum) { ++lol1; ++k; } cout<<lol1<<endl; while( i < lol1 ) { cout << lol + j << " "; j++; i++; } cout << lol + j << endl; } |
|
|