Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:本题的详尽解析In Reply To:本题的详尽解析 Posted by:csj at 2008-02-01 11:39:09 > jimmyzzxhlh 网友已经贴了一份解答,我的想法与他稍有不同,但最后推出的公式是一样的: > > 我并没有从The Money customer gets = The money James lost这方面来想,而是: > > (卖价)M + (找给顾客的钱)C = 收到的钱 > > 收到的钱 - (假币)P - (成本)N - (找给顾客的钱)C = 商人赚到的钱 > > 因此,商人赚到的钱 = M + C - P - N - C = M - P - N > > 由于题目要求的是商人损失的钱,只要取相反数即可: P + N - M > > 由于这题的编程难度跟A+B没什么区别,所以我贴代码应该不会有人有意见的~哈哈,满足一下贴码欲。 > > 参考代码(C++) > > #include <stdio.h> > > int main() > { > int n,m,p,c; > scanf("%d%d%d%d",&n,&m,&p,&c); > while((n|m|p|c)!=0) > { > printf("%d\n",n+p-m); > scanf("%d%d%d%d",&n,&m,&p,&c); > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator