正文

10512006-06-09 19:12:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/bakers/15628.html

分享到:

More Flowers,More Love Time Limit:1000MS  Memory Limit:65536KTotal Submit:30 Accepted:13 Description Valentine's Day is coming,while girls are preparing chocolate for their boys, we boys is also in preparation of choosing presents for the sweet to love carefully. Tom is Tom,Tom does not know too much about how to flattering the girl in his heart, so he just decides to buy flowes for his girl as what the knights in middle ages have already done. However thought he could do more than buying flowers, he wants to use out all the money in his pockets on flowers,because he loves his girl too much. There are three kinds of flowers in the florist: Rose, Carnation and Rosebush. Tom wants to know if he could use out of his money. Please tell him, our genius programmer. Input The input file contains multiple lines, and each line contains four numbers in sequence, the total money that Tom has, the price of Rose, the price of Carnation and of Rosebush. Output For each test case output Yes if Tom could use out his money or No if not. Sample Input 100 1 1 1 50 3 3 3 Sample Output Yes No   Source #include"iostream" using namespace std; struct { int money; int rose; int ca; int rb; }a[100]; bool use(int i) { int m,j,k; for(m=0;m<=a[i].money/a[i].rose;m++) for(j=0;j<=a[i].money/a[i].ca;j++) for(k=0;k<=a[i].money/a[i].rb;k++) if(m*a[i].rose+j*a[i].ca+k*a[i].rb==a[i].money)return true; return false; } int main() { int i=0,j; while(cin>>a[i].money>>a[i].rose>>a[i].ca>>a[i].rb) i++; for(j=0;j<i;j++) if(use(j))cout<<"Yes"<<endl; else cout<<"No"<<endl; return 1; }

阅读(3722) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册