hust 1170 - Baskets of Gold Coins
2014-06-14 10:51
253 查看
题目描述
YouaregivenNbasketsofgoldcoins.Thebasketsarenumberedfrom1toN.Inallexceptoneofthebaskets,eachgoldcoinweighswgrams.Intheoneexceptionalbasket,eachgoldcoinweighsw-dgrams.Awizardappearsonthesceneandtakes1coinfromBasket1,2coinsfromBasket2,andsoon,uptoandincludingN-1coinsfromBasketN-1.HedoesnottakeanycoinsfromBasketN.HeweighstheselectedcoinsandconcludeswhichoftheNbasketscontainsthelightercoins.Yourmissionistoemulatethewizard'scomputation.
输入
Theinputfilewillconsistofoneormorelines;eachlinewillcontaindataforoneinstanceoftheproblem.Morespecifically,eachlinewillcontainfourpositiveintegers,separatedbyoneblankspace.Thefirstthreeintegersare,respectively,thenumbersN,w,andd,asdescribedabove.Thefourthintegeristheresultofweighingtheselectedcoins.Nwillbeatleast2andnotmorethan8000.Thevalueofwwillbeatmost30.Thevalueofdwillbelessthanw.
输出
Foreachinstanceoftheproblem,yourprogramwillproduceonelineofoutput,consistingofonepositiveinteger:thenumberofthebasketthatcontainslightercoinsthantheotherbaskets.
样例输入
样例输出
作者chensunrise
YouaregivenNbasketsofgoldcoins.Thebasketsarenumberedfrom1toN.Inallexceptoneofthebaskets,eachgoldcoinweighswgrams.Intheoneexceptionalbasket,eachgoldcoinweighsw-dgrams.Awizardappearsonthesceneandtakes1coinfromBasket1,2coinsfromBasket2,andsoon,uptoandincludingN-1coinsfromBasketN-1.HedoesnottakeanycoinsfromBasketN.HeweighstheselectedcoinsandconcludeswhichoftheNbasketscontainsthelightercoins.Yourmissionistoemulatethewizard'scomputation.
输入
Theinputfilewillconsistofoneormorelines;eachlinewillcontaindataforoneinstanceoftheproblem.Morespecifically,eachlinewillcontainfourpositiveintegers,separatedbyoneblankspace.Thefirstthreeintegersare,respectively,thenumbersN,w,andd,asdescribedabove.Thefourthintegeristheresultofweighingtheselectedcoins.Nwillbeatleast2andnotmorethan8000.Thevalueofwwillbeatmost30.Thevalueofdwillbelessthanw.
输出
Foreachinstanceoftheproblem,yourprogramwillproduceonelineofoutput,consistingofonepositiveinteger:thenumberofthebasketthatcontainslightercoinsthantheotherbaskets.
样例输入
102581109 102581045 80003012959879400
样例输出
2 10 50 这个题目个人认为第二个样例是有问题的,这个题在hdu上也有,不过在hdu上longlong是不通过的,所以个人觉得hdu这样一个大平台,应该多兼容一下,要不会影响很多人的发挥,就像这次百度之星一样,有很多人就死在longlong和__int64的手里
#include<map> #include<set> #include<stack> #include<queue> #include<cmath> #include<vector> #include<cstdio> #include<string> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #defineinf0x0f0f0f0f usingnamespacestd; intmain() { //freopen("in.txt","r",stdin); intsum,n,w,d,ans; while(scanf("%d%d%d%d",&n,&w,&d,&sum)!=EOF) { ans=(((n*(n-1))/2)*w-sum)/d; if(ans==0)printf("%d\n",n); elseprintf("%d\n",ans); } return0; }
作者chensunrise
相关文章推荐
- HDU 2401 Baskets of Gold Coins
- HDU 2401 Baskets of Gold Coins
- HDU2401 Baskets of Gold Coins【水题】【推理】
- 杭电acm- 2401 Baskets of Gold Coins
- Baskets of Gold Coins
- hdu2401 Baskets of Gold Coins
- 杭电2410Baskets_Of_Gold_Coins
- HDOJ 2401 Baskets of Gold Coins
- HDOJ 2401 Baskets of Gold Coins (数学题)
- HDU-2401-Baskets of Gold Coins
- Baskets of Gold Coins 2401
- HDU 2401.Baskets of Gold Coins
- hdu 2401 Baskets of Gold Coins
- hdu 2401 Baskets of Gold Coins
- HDOJ(HDU) 2401 Baskets of Gold Coins(数列、)
- HDOJ(HDU) 2401 Baskets of Gold Coins(数列、)
- hdoj 2401 Baskets of Gold Coins
- HDU 2401:Baskets of Gold Coins
- HDU 2401 Baskets of Gold Coins
- hdu 2401 Baskets of Gold Coins