Baskets of Gold Coins

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1862    Accepted Submission(s): 1108

Problem Description
You
are given N baskets of gold coins. The baskets are numbered from 1 to
N. In all except one of the baskets, each gold coin weighs w grams. In
the one exceptional basket, each gold coin weighs w-d grams. A wizard
appears on the scene and takes 1 coin from Basket 1, 2 coins from Basket
2, and so on, up to and including N-1 coins from Basket N-1. He does
not take any coins from Basket N. He weighs the selected coins and
concludes which of the N baskets contains the lighter coins. Your
mission is to emulate the wizard's computation.

 
Input
The
input file will consist of one or more lines; each line will contain
data for one instance of the problem. More specifically, each line will
contain four positive integers, separated by one blank space. The first
three integers are, respectively, the numbers N, w, and d, as described
above. The fourth integer is the result of weighing the selected coins.

N will be at least 2 and not more than 8000. The value of w will be at most 30. The value of d will be less than w.

 
Output
For
each instance of the problem, your program will produce one line of
output, consisting of one positive integer: the number of the basket
that contains lighter coins than the other baskets.

 
Sample Input
10 25 8 1109
10 25 8 1045
8000 30 12 959879400
 
Sample Output
2
10
50
题解:这道题就是说有N个篮子,从1到N-1每个篮子取硬币个数为1.....N-1;
其中有一个篮子的每个硬币价值为w-d,剩余的篮子每个硬币价值为w;
 求这个特殊的篮子取得硬币个数;
思路就是sum是否等于(n-1+1)*(n-1)/2  *w;等于证明这个特殊的篮子没有被取;
代码:
#include<stdio.h>
#include<string.h>
int main(){
int n,w,d,sum;
while(~scanf("%d%d%d%d",&n,&w,&d,&sum)){
int x=w*((n-+)*(n-)/)-sum;
if(x==)printf("%d\n",n);
else printf("%d\n",x/d);
}
return ;
}

Baskets of Gold Coins的更多相关文章

  1. hdoj 2401 Baskets of Gold Coins

    Baskets of Gold Coins Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  2. HDOJ(HDU) 2401 Baskets of Gold Coins(数列、)

    Problem Description You are given N baskets of gold coins. The baskets are numbered from 1 to N. In ...

  3. Baskets of Gold Coins_暴力

    Problem Description You are given N baskets of gold coins. The baskets are numbered from 1 to N. In ...

  4. Gold Coins 分类: POJ 2015-06-10 15:04 16人阅读 评论(0) 收藏

    Gold Coins Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21767   Accepted: 13641 Desc ...

  5. OpenJudge/Poj 2000 Gold Coins

    1.链接地址: http://bailian.openjudge.cn/practice/2000 http://poj.org/problem?id=2000 2.题目: 总Time Limit: ...

  6. H - Gold Coins(2.4.1)

    H - Gold Coins(2.4.1) Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:3000 ...

  7. poj 2000 Gold Coins(水题)

    一.Description The king pays his loyal knight in gold coins. On the first day of his service, the kni ...

  8. poj 2000 Gold Coins

    题目链接:http://poj.org/problem?id=2000 题目大意:求N天得到多少个金币,第一天得到1个,第二.三天得到2个,第四.五.六天得到3个....以此类推,得到第N天的金币数. ...

  9. Gold Coins

    http://poj.org/problem?id=2000 #include<stdio.h> ; int main() { int coin[N]; ,j,k; j = ; k = ; ...

随机推荐

  1. 写给初学者css优先级问题

    首先需要搞清楚几个基本概念 1.内嵌样式: 写在元素标签内的例如:<div style="background-color:red"> </div> 2.内 ...

  2. 有关于/home出现100%被占用 与 vnc的关系

    我在远程服务器时,通常使用的程序是vnc.因为vnc可以图形化界面,操作效果比用putty好很多. 但是,我发现使用vnc有一个问题,就是/home占用空间会达到100%. [zy@islab62 ~ ...

  3. 【Daily】 2014-4-28

    KEEP GOING  表达产品想法, 探讨产品问题, 倾听可能性问题. 一次就做好, 有成果展示, 主动展示 先确立图, 后确立代码. Hold dream, and never let it go ...

  4. Ubuntu之修改用户名和主机名

    记得曾几何时,想把自己电脑的“乌班兔儿”取个响亮的名字,但是问了很久度娘和谷哥,都要我把当前用户删除了(userdel -r xxx),重新建一个用户(adduser xxx),但是,我的电脑是所有环 ...

  5. node配置运行环境变量;

    node express 在开发环境和生产环境运行的代码是不一样的, 通常是先配置好的,在开发环境运行一套代码,在生产环境运行另一套代码, 开发环境 development, 生产环境producti ...

  6. 警告框和操作表(IOS开发)

    警告框(AlertView)时模态的,不关闭它就不能做其它事情,所以不是下面几种情况不应该随便使用. 1.应用不能继续执行. 如内存不足,没有网络.一般仅仅须要一个button. 2.询问还有一个解决 ...

  7. mysql数据库日期是varchar类型的时间比较查询

     单纯的字符串比较结果不精确. select * from 表明 where times> '2088/12/8 10:02:40' (×) 转换函数如下(数据库为varchar): selec ...

  8. winform CheckedListBox实现全选/全不选

    /全选         private void button3_Click(object sender, EventArgs e)         {             for (int i ...

  9. UITextField总结--博主总结的真好

    忍不住copy过来http://www.cnblogs.com/wengzilin/archive/2012/03/13/2393985.html 还有些不错的博客推荐给大家http://blog.c ...

  10. 转载:C# Office 开发

    原文地址:http://blog.sina.com.cn/s/blog_604fb7ae0100x2s7.html 中小企业办公自动化系统都需要有与微软办公软件连接的功能,如把数据导入到电子表格.Wo ...