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的更多相关文章

  1. poj 2000 Gold Coins(水题)

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

  2. poj 2000 Gold Coins

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

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

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

  4. hdoj 2401 Baskets of Gold Coins

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

  5. 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 ...

  6. Baskets of Gold Coins

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

  7. H - Gold Coins(2.4.1)

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

  8. OpenJudge/Poj 1661 帮助 Jimmy

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

  9. OpenJudge/Poj 1753 Flip Game

    1.链接地址: http://bailian.openjudge.cn/practice/1753/ http://poj.org/problem?id=1753 2.题目: 总时间限制: 1000m ...

随机推荐

  1. Redis实战之Redis + Jedis

    用Memcached,对于缓存对象大小有要求,单个对象不得大于1MB,且不支持复杂的数据类型,譬如SET 等.基于这些限制,有必要考虑Redis! 相关链接: Redis实战 Redis实战之Redi ...

  2. SQL Server磁盘I/O性能分析

    SQL Server中的I/O操作类型: 1.对于内存中没有缓存的数据,第一次访问时需要将数据从所在的页面从数据文件中读取到内存中 2.在任何Insert/Update/Delete提交前,SQL S ...

  3. ThinkPHP CURD方法盘点:data方法

    data方法也是模型类的连贯操作方法之一,用于设置当前要操作的数据对象的值,可能大家不太习惯用这个方法,今天来讲解下如何用好data方法. 用法 写操作 通常情况下我们都是通过create方法或者赋值 ...

  4. 声明:function FileSetAttr ( const FileName : string

    对文件和文件夹都有效  FileSetAttr('D:\Administrator\Desktop\patcher\Win32\Release\config\element\update',faHid ...

  5. php中setcookie函数用法详解(转)

    php中setcookie函数用法详解:        php手册中对setcookie函数讲解的不是很清楚,下面是我做的一些整理,欢迎提出意见.        语法:        bool set ...

  6. Google stuff

    Google Pro Tip: Use Back-of-the-envelope-calculations to Choose the Best Design - High Scalability - ...

  7. java_TreeSet 定制排序实例

    package ming; import java.util.Comparator; import java.util.TreeSet; class M { int age; public M(int ...

  8. iOS给背景添加点击事件

    当点击背景的时候出发事件,或者跳转界面或者产生其他的响应 -(void)viewDidLoad { UIImageView * imageView  = [UIImageView alloc]init ...

  9. C语言结构体赋值2

    #include <stdio.h> /** 上一个版本的name是固定大小的,不好,这次换用 *name然后 采用 堆的方式申请内存,起到用到少拿多少的一个方式. */ struct s ...

  10. 深入理解计算机系统第二版习题解答CSAPP 2.18

    将32位补码表示的数转换为10进制数. 32位补码 十进制 0x1b8 0x14 0xFFFFFE58 -424 0xFFFFFE74 -396 0x44 0xFFFFFEC8 -312 0x10 0 ...