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 ...
随机推荐
- Jsp中的pageContext对象
这个对象代表页面上下文.组要用于访问页面共享数据.使用pageContext可以直接访问request,session,application范围的属性,看看这些jsp的页面: JSP 页面使用 pa ...
- SQLSERVER复制表的方法
1.复制表结构及数据 格式:select * into 新表名 from 要复制的表名 --例如:select * into temp from users 2.只复制表数据 格式 ...
- C++中的头文件和源文件
一.C++编译模式 通常,在一个C++程序中,只包含两类文件——.cpp文件和.h文件.其中,.cpp文件被称作C++源文件,里面放的都是C++的源代码:而.h文件则被称作C++头文件,里面放的也是C ...
- windows7怎么共享文件夹
http://jingyan.baidu.com/article/d45ad148f06fef69552b80e6.html
- Servlet, Listener 、 Filter.
Java Web的三大组件:Servlet, Listener . Filter. 使用Listener监听器:八大监听器: 第一组:用于监听Servlet三个域对象的创建与销毁 1. Servlet ...
- Programme skills
1. Dynamic library 2. Template class. function template<typename T> classs Sample { ... templa ...
- 命令行界面下的用户和组管理之usermod的使用
当使用useradd添加好用户之后,想要做一些修改,这时需要用到usermod命令. 功能说明:修改用户帐号的各项信息. 语 法:usermod [-L | U][-c <备注>][-d ...
- 如何使用gcc编译器
开始... 首先,我们应该知道如何调用编译器.实际上,这很简单.我们将从那个著名的第一个C程序开始. #include <stdio.h> int main() { printf(&quo ...
- js定时器window.setTimeout和setInterval
window.setTimeout(function(){ document.getElementById("editorindex&q ...
- 有关line-height的见解
line-height:简单的说就是行高,是两行文字之间基线的距离.基线是指在英语的书写的4线3格中,从上往下数的第三条线 1.line-height与行内框盒子模型 所有内联元素的样式表现都与行内框 ...