H - Gold Coins(2.4.1)

Crawling in process...
Crawling failed
Time Limit:1000MS    
Memory Limit:30000KB     64bit IO Format:%I64d & %I64u

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

#include<stdio.h>
#include<string.h>
int main()
{
int day,i,sum,pay,c;//pay,要付的金币个数;c,计数器
while(scanf("%d",&day) && day!=0)
{
sum=0;
pay=1;
c=0;
for(i=1;i<=day;i++)
{
sum+=pay;
c++;
if(c==pay)
{
c=0;
pay++;
}
}
printf("%d %d\n",day,sum);
}
return 0;
}

H - Gold Coins(2.4.1)的更多相关文章

  1. OpenJudge/Poj 2000 Gold Coins

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

  2. hdoj 2401 Baskets of Gold Coins

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

  3. Baskets of Gold Coins

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

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

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

  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. poj 2000 Gold Coins(水题)

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

  7. Gold Coins

    http://poj.org/problem?id=2000 #include<stdio.h> ; int main() { int coin[N]; ,j,k; j = ; k = ; ...

  8. poj 2000 Gold Coins

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

  9. Baskets of Gold Coins_暴力

    Problem Description You are given N baskets of gold coins. The baskets are numbered from 1 to N. In ...

随机推荐

  1. VS2017不能打开stdio.h等文件

    从另一台机器上复制过来的项目,由于两台机器的库目录不一致,导致了stdio.h等很多文件都打不开: 解决的办法是从新设置包含目录.选择项目-->%项目名称%属性-->VC++目录,设置包含 ...

  2. 一些Vim使用的小技巧

    1. 全局替换(1) v + G + $ 选定全部,然后输入 :s/原始字符串/目标字符串/(2) :%s/原始字符串/目标字符串/ 2. 清除页面中所有行尾的空白符::%s/s+$// 3. 清除所 ...

  3. iOS开源项目之日志框架CocoaLumberjack

    CocoaLumberjack是Mac和iOS上一个集快捷.简单.强大和灵活于一身的日志框架.CocoaLumberjack类似于流行的日志框架(如log4j),但它是专为Objective-C设计的 ...

  4. 重写$.ajax方法

    /*重写Jquery中的ajax 封装壳*/ $(function () { (function ($) { //首先备份下jquery的ajax方法 var _ajax = $.ajax; //重写 ...

  5. Window开启上帝模式

    所谓的上帝模式就是所有功能在一个文件下,方便.快捷地操作! 01.新建一个文件夹 02.重命名文件夹 文件夹重命名为“GodMode.{ED7BA470-8E54-465E-825C-99712043 ...

  6. 安装babel遇到的异常

    Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure ...

  7. CDN介绍

    作者:视界云链接:https://www.zhihu.com/question/37353035/answer/175217812来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注 ...

  8. 最近对latin-1这个字符集产生了不少好感

    [简介] 最近我要解析一个数据库中间件的日志.这个中间件会在日志中记录SQL发往的后台DB ,执行耗时,对应的SQL:中间件直接把SQL写到 了日志中去,并没有对SQL进行适当的编码转换:理想情况下这 ...

  9. ceph crush 之 crush_do_rule

      crush_do_rule中,用了一个scratch空间来完成item的搜索. scratch空间总共有3个max_result这么大,并且按照max_result长度划分为三个部分(下图中的a. ...

  10. idea 添加项目到svn

    version control 改变项目为svn管理 如图  分享 share dic 添加新地址 share 剩下的 就是设置忽略目录 提交