Baskets of Gold Coins
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
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 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.
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.
10 25 8 1045
8000 30 12 959879400
10
50
#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的更多相关文章
- hdoj 2401 Baskets of Gold Coins
Baskets of Gold Coins Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- 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 ...
- Baskets of Gold Coins_暴力
Problem Description You are given N baskets of gold coins. The baskets are numbered from 1 to N. In ...
- Gold Coins 分类: POJ 2015-06-10 15:04 16人阅读 评论(0) 收藏
Gold Coins Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21767 Accepted: 13641 Desc ...
- OpenJudge/Poj 2000 Gold Coins
1.链接地址: http://bailian.openjudge.cn/practice/2000 http://poj.org/problem?id=2000 2.题目: 总Time Limit: ...
- H - Gold Coins(2.4.1)
H - Gold Coins(2.4.1) Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:3000 ...
- poj 2000 Gold Coins(水题)
一.Description The king pays his loyal knight in gold coins. On the first day of his service, the kni ...
- poj 2000 Gold Coins
题目链接:http://poj.org/problem?id=2000 题目大意:求N天得到多少个金币,第一天得到1个,第二.三天得到2个,第四.五.六天得到3个....以此类推,得到第N天的金币数. ...
- Gold Coins
http://poj.org/problem?id=2000 #include<stdio.h> ; int main() { int coin[N]; ,j,k; j = ; k = ; ...
随机推荐
- React 同构
React 同构 搬运 https://segmentfault.com/a/1190000004671209 究竟什么是同构呢? 同构就是希望前端 后端都使用同一套逻辑 同一套代码 Nodejs出现 ...
- SysLog解析
SysLog的标准是RFC3164描述的,但是很多厂家的日志都没有完全遵守这个标准,因此在SIEM和SEM中,日志解析就是第一个要面对的问题,因此,就我所看到的大部分SOC厂家(国内和国外)都需要针对 ...
- Java调用.dll文件
因为项目的需求,要在JAVA项目中调用Windows的Dll(动态链接库)文件,之前用Jni调用过C写的Dll文件,比较麻烦,这里不多说,网上也有很多这方面的文档.在网上找到一个开源的组件JNativ ...
- 全国计算机等级考试二级教程-C语言程序设计_第11章_对函数的进一步讨论
无论传递什么参数,函数都有副本机制 改变一个变量,需要传入变量的地址 改变一个指针变量,需要传入指针变量的地址 //int add(int a, int b);挖取函数声明 //int ()(int ...
- cf-公式专场
A. Again Twenty Five! time limit per test 0.5 seconds memory limit per test 64 megabytes input stand ...
- AU3学习笔记
目录 1. AU3是什么?能做什么? 2. 乱学AU3中的命令(语言相关)? 3. 通过简单示例学习AU3? 4. 正则表达式的学习(对大小写敏感) 5.对于GUI的相关学习 1. AU ...
- 关于在用Swift开发iOS时如何隐藏NavigationBar和TabBar
举个例子:如果我有一个页面需要进入时同时隐藏NavigationBar和TabBar,那么我就在那个页面的ViewController的代码里加上下面的代码.就可以实现了.接下来告诉大家每一块要注意的 ...
- INPUT[type=file]的change事件不触发问题
在网页上要操作文件通常会使用INPUT[type=file]控件,但这个控件的设计很蛋疼.它不像其它编程语言中文件选择后会触发一个事件,只是让上面的文字改变,而这个改变可能会触发change事件而已. ...
- R语言初涉
R语言简单的函数的使用: “<-”表示赋值,也可以用“=”. c()为连接函数,连接中间的数据表示向量,连接中间的数据表示向量,X1 <- c()表示用一组数据为变量X1赋值. mean( ...
- /-- Encapsulated exception ------------\ java.lang.NoSuchMethodException: com.sjzdaj.po.Class.setN_id([Ljava.lang.String;)
转自:http://ruinxdgzy.iteye.com/blog/805138