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. mysql 索引建立

    如何建立mysql索引? 创建索引原则 1.左前缀原则 : mysql索引匹配会从右匹配,到遇到( >  < between like)终止.如 我们建立索引(a,b,c,d), a = ...

  2. C#-设置窗体在显示器居中显示

    在窗体的属性中查看:StartPosition属性,该属性的设置中有一个"CenterScreen"的选择项,该项就是设置窗体局中显示的.

  3. nginx利用image_filter动态生成缩略图

    转自:http://www.nginx.cn/2160.html "我如今是有些图片须要生成缩略图.这个如今加了image_filter这个已经实现了.但我不知道怎么样才干訪问我上传的原图& ...

  4. UITableViewCell 高度自适应

    UITableViewCell 高度自适应一直是我们做动态Cell高度时遇到的最烦躁的问题,Cell动态高度计算可以去看看sunny的这篇文章介绍,今天主要和大家分享下我在使用systemLayout ...

  5. 兼容:判断 iframe 是否加载完成

    判断 iframe 是否加载完成其实与 判断 JavaScript 文件是否加载完成 采用的方法很类似 var iframe = document.createElement("iframe ...

  6. 去掉html标签和空格等

    <?php$str = '<span style="color:#f00;">good; world</span>';echo $str.'<b ...

  7. Struts2中的类型转换

    1.     Struts2中的类型转换 我们知道通过HTTP提交到后台的数据,都是字符串的形式,而我们需要的数据类型当然不只字符串类型一种.所以,我们需要类型转换! 在Struts2中,类型转换的概 ...

  8. [Effective C++ --005]了解C++默默编写并调用哪些函数

    <前言>编译器是个十分敬业的工作者,不但为你编译代码,甚至为你生成代码,不可思议吧.本文主要介绍编译器究竟会为我们生成和调用哪些代码. <空类和非空类>如果问什么样的类是空类? ...

  9. Model

    using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace iFlytekDemo ...

  10. Using zend-navigation in your Album Module

    Using zend-navigation in your Album Module In this tutorial we will use the zend-navigation componen ...