OpenJudge/Poj 2000 Gold Coins
1.链接地址:
http://bailian.openjudge.cn/practice/2000
http://poj.org/problem?id=2000
2.题目:
- 总Time Limit:
- 1000ms
- Memory Limit:
- 65536kB
- Description
- The king pays his loyal knight in gold coins. On the first day of his service, the knight receives one gold coin. On each of the next two days (the second and third days of service), the knight receives two gold coins. On each of the next three days (the fourth, fifth, and sixth days of service), the knight receives three gold coins. On each of the next four days (the seventh, eighth, ninth, and tenth days of service), the knight receives four gold coins. This pattern of payments will continue indefinitely: after receiving N gold coins on each of N consecutive days, the knight will receive N+1 gold coins on each of the next N+1 consecutive days, where N is any positive integer.
Your
program will determine the total number of gold coins paid to the
knight in any given number of days (starting from Day 1).- Input
- The input contains at least one, but no more than 21 lines. Each
line of the input file (except the last one) contains data for one test
case of the problem, consisting of exactly one integer (in the range
1..10000), representing the number of days. The end of the input is
signaled by a line containing the number 0.- Output
- There is exactly one line of output for each test case. This line
contains the number of days from the corresponding line of input,
followed by one blank space and the total number of gold coins paid to
the knight in the given number of days, starting with Day 1.- Sample Input
10
6
7
11
15
16
100
10000
1000
21
22
0- Sample Output
10 30
6 14
7 18
11 35
15 55
16 61
100 945
10000 942820
1000 29820
21 91
22 98- Source
- Rocky Mountain 2004
3.思路:
4.代码:
#include "stdio.h"
#include "stdlib.h"
#include "math.h"
int main()
{
int a,b;
int i;
int sum;
scanf("%d",&a);
while(a!=)
{
sum=;
b=(sqrt(*a+)-)/;
for(i=;i<=b;i++)
{
sum+=i*i;
}
sum+=(b+)*(a-b*(b+)/);
printf("%d %d\n",a,sum);
scanf("%d",&a);
}
return ;
}
OpenJudge/Poj 2000 Gold Coins的更多相关文章
- 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 分类: POJ 2015-06-10 15:04 16人阅读 评论(0) 收藏
Gold Coins Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21767 Accepted: 13641 Desc ...
- 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
Baskets of Gold Coins Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- H - Gold Coins(2.4.1)
H - Gold Coins(2.4.1) Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:3000 ...
- OpenJudge/Poj 1661 帮助 Jimmy
1.链接地址: bailian.openjudge.cn/practice/1661 http://poj.org/problem?id=1661 2.题目: 总Time Limit: 1000ms ...
- OpenJudge/Poj 1753 Flip Game
1.链接地址: http://bailian.openjudge.cn/practice/1753/ http://poj.org/problem?id=1753 2.题目: 总时间限制: 1000m ...
随机推荐
- java Swing图形化界面
学过java的人应该对java的图形化界面很是反感,特别是接触java不久的人.如果想和其他语言那样用鼠标拖拽,可以使用wondosbulider插件.但是用起来也不是那么方便.当然对于不乐意写代码的 ...
- uva 11246 - K-Multiple Free set(数论)
题目链接:uva 11246 - K-Multiple Free set 题目大意:给定n,k.求一个元素不大于n的子集,要求该子集的元素尽量多,而且不含两个数满足a∗k=b. 解题思路:容斥原理.f ...
- Android设备上i-jetty环境的搭建-手机上的web服务器
本文主要跟大家分享如何将一台Android设备打造成一个web服务器使用. 编译i-jetty 1.将源码download下来,http://code.google.com/p/i-jetty/dow ...
- paip.mysql 5.6 安装总结
paip.mysql 5.6 安装总结 作者Attilax , EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.csdn.net/atti ...
- iOS UIView 基本属性用法
.创建UIView UIView * redView = [[UIView alloc] initWithFrame:CGRectMake(, , , )]; UIView * blueView = ...
- Spring MVC page render时jsp中元素相对路径的解决办法
前段时间做了用Spring Security实现的登录和访问权限控制的功能,但是page render使用的是InternalResourceResolver,即在spring的servlet配置文件 ...
- WebService 设计总结
接触过非常多电商的WebService,有种一看就蛋疼的设计,今天要从这个反例说一说 WebService 的设计. [WebMethod] public string QueryOrderDetai ...
- el表达式跟ognl表达式的区别(转)
EL表达式: >>单纯在jsp页面中出现,是在四个作用域中取值,page,request,session,application.>>如果在struts环境中,它除了有在上面的 ...
- open_table与opened_table --2
好多人在调优Mysql的时候,总是对open_tables和opend_tables两个参数分别不清. 网上好多解释都是这样的:open_tables:当前打开表的数量opened_tables:当前 ...
- careercup-中等难度 17.3
17.3 写一个算法计算n的阶乘末尾0的个数? 解答: 首先,算出n的阶乘的结果再去计算末尾有多少个0这种方法是不可取的, 因为n的阶乘是一个非常大的数,分分种就会溢出.我们应当去分析, 是什么使n的 ...