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

本文共 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

你可能感兴趣的文章
阿里百川码力APP监控 来了!
查看>>
使用dotenv管理环境变量
查看>>
温故js系列(11)-BOM
查看>>
Vuex学习
查看>>
bootstrap - navbar
查看>>
切图崽的自我修养-[ES6] 编程风格规范
查看>>
[React Native Android 安利系列]样式与布局的书写
查看>>
利用dxflib读写cad文件
查看>>
服务器迁移小记
查看>>
FastDFS存储服务器部署
查看>>
Android — 创建和修改 Fragment 的方法及相关注意事项
查看>>
流程控制: jQ Deferred 与 ES6 Promise 使用新手向入坑!
查看>>
swift基础之_swift调用OC/OC调用swift
查看>>
Devexpress 15.1.8 Breaking Changes
查看>>
推荐JS插件:imagesLoaded,监测图片加载情况并提供相应的事件(加载成功/失败)...
查看>>
Java B2B2C多用户商城 springcloud架构- common-service 项目构建过程(七)
查看>>
杨老师课堂之ArrayList集合常用方法解析
查看>>
ElasticSearch Client详解
查看>>
新零售讲堂之时代下的传统零售业,何去何从?
查看>>
c++读取和写入TXT文件的整理
查看>>