博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[2000]Gold Coins(水题)POJ
阅读量:7224 次
发布时间:2019-06-29

本文共 2083 字,大约阅读时间需要 6 分钟。


Online Judge Problem Set Authors Online Contests User
Prob.ID:
Current Contest
Language: Default
                                                                               Gold Coins
Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 21098 Accepted: 13232

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

106711151610010000100021220

Sample Output

10 306 147 1811 3515 5516 61100 94510000 9428201000 2982021 9122 98

Source

#include 
#include
#include
int a[10100];int main(){ int n,i,j; int k=1; a[0]=0; for(i=1;i<=10000;i++)//为什么把这段循环语句在此处??若此循环放进while语句会怎样??(思考) { for(j=i;j


×
复制
复制全部

转载于:https://www.cnblogs.com/jiangyongy/p/3971596.html

你可能感兴趣的文章
结构体类型
查看>>
SQL SERVER数据库 三种 恢复模式
查看>>
android.os.NetworkOnMainThreadException的解决方案
查看>>
16、SpringBoot-CRUD错误处理机制(3)
查看>>
Selenium 安装与配置及webdriver的API与定位元素
查看>>
git 覆盖本地变化
查看>>
Java中的内存分配机制
查看>>
找回Gnome菜单下的关机键
查看>>
[转载] 中华典故故事(孙刚)——07 二百五
查看>>
[转载] 中华典故故事(孙刚)——09 挂羊头_卖狗肉
查看>>
GitKraken使用教程-基础部分(2)
查看>>
PHP设计模式 -- 注册模式
查看>>
iframe和DataForm
查看>>
CQOI2019(十二省联考)游记
查看>>
【总结整理】需求分析所需掌握技能(转)
查看>>
我的软件之路
查看>>
EL表达式
查看>>
日期(date)运用座谈会
查看>>
能率燃气热水器售后好差啊!
查看>>
python常见问题
查看>>