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 = ; ...
随机推荐
- 自定义清除重复uses-permission申明的AS插件
分享一个我刚到天下布医工作时,写的一个android studio插件. 做安卓项目时,经常继承一些第三方sdk,这些sdk都会申请权限,导致AndroidManifest.xml中的uses-per ...
- xxx.java: Recompile with -Xlint:unchecked for details.
一.遇到问题:用ant执行jasperreport的samples/charts示例的build.xml时,无法编译,提示错误如下:javac: [javac] Compiling 2 sour ...
- Git与SVN的比较及优点
前天处女面被问到了你为什么要用Git而不用SVN,答的不是很理想,正好今天晚上小组内部进行了Git使用的培训,便想着总结一下Git与SVN的差异以及Git的优点. 一.Git与SVN的比较 1.git ...
- 10-2[RF] OOB validation
main idea: 在使用bootstrap生成gi的训练集时,会有一部分数据没有被选中,使用这一部分数据(OOB)进行validation. 1.数据没有被选中的概率 假设训练集大小为N,使用bo ...
- html系列教程--base button canvas caption
<base> 标签 <base> 标签为页面上的所有链接规定默认地址或默认. demo: <head> <base href="http://www ...
- i = i++ 在java字节码层面的分析
有这么一段代码: package zl.test; public class PcodeTest { /** * @param args */ public static void main(Stri ...
- windows下的mongodb下载安装
1.首先从官网https://www.mongodb.org/下载mongodb的安装包,本人下载的是mongoDB3.2版本的.msi的文件,然后双击安装即可 2.点击next 3.compelte ...
- jquery.validate校验文件使用说明
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation 一导入js库<script src="../js/ ...
- poj2478--欧拉函数打表
此题中对时间有要求,如直接使用欧拉函数求解,每输入一个n,就得进行循环求出<n的每个数的欧拉函数, 这样会超时, 于是我们可预先将欧拉函数打表, 再进行一个循环加法运算,便可不超时得解. #in ...
- PHP 提交checkbox表单时 判断复选框是否被选中
function GetTitleImgPath(){ $titleImgPath = ""; if (isset($_POST["titlecheckbox" ...