H - Gold Coins(2.4.1)
Crawling in process...
Crawling failed
Time Limit:1000MS
Memory Limit:30000KB 64bit IO Format:%I64d & %I64u
Description
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 number of days. The end of the input is signaled by a line containing the number 0.
Output
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)的更多相关文章
- OpenJudge/Poj 2000 Gold Coins
1.链接地址: http://bailian.openjudge.cn/practice/2000 http://poj.org/problem?id=2000 2.题目: 总Time Limit: ...
- hdoj 2401 Baskets of Gold Coins
Baskets of Gold Coins Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- Baskets of Gold Coins
Baskets of Gold Coins Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- Gold Coins 分类: POJ 2015-06-10 15:04 16人阅读 评论(0) 收藏
Gold Coins Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21767 Accepted: 13641 Desc ...
- 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 ...
- poj 2000 Gold Coins(水题)
一.Description The king pays his loyal knight in gold coins. On the first day of his service, the kni ...
- Gold Coins
http://poj.org/problem?id=2000 #include<stdio.h> ; int main() { int coin[N]; ,j,k; j = ; k = ; ...
- poj 2000 Gold Coins
题目链接:http://poj.org/problem?id=2000 题目大意:求N天得到多少个金币,第一天得到1个,第二.三天得到2个,第四.五.六天得到3个....以此类推,得到第N天的金币数. ...
- Baskets of Gold Coins_暴力
Problem Description You are given N baskets of gold coins. The baskets are numbered from 1 to N. In ...
随机推荐
- WIN10平板如何打开文件夹选项
打开计算机,然后查看,最后可以找到选项
- python2中在sqlite3中插入中文
# -*- coding: utf-8 -*- import sqlite3 conn = sqlite3.connect('SWC_Perf_Info.db') cur = conn.cursor( ...
- android makefile文件批量拷贝文件的方法
该方法是shell 和makefile组合使用 wallpapers := $(shell ls packages/apps/hyst_apps/NewBingoLauncher_C/default_ ...
- 【转】CLR和JIT的理解、.NET反汇编学习
CLR:通用语言运行时(Common Language Runtime)的简称,CLR是.NET框架的核心内容之一,可以把它看为一套标准资源,可以呗任何.NET程序使用.它包括:面向对象的编程模型.安 ...
- MySQL的reset slave与reset slave all
reset slave是各版本Mysql都有的功能,可以让slave忘记自己在master binary log中的复制位置. reset slave命令主要完成以下工作内容: -删除master.i ...
- 转 HashMap 比较透彻的分析
HashMap 的实现原理 原文: HashMap 的实现原理 众所周知,HashMap是用来存储Key-Value键值对的一种集合,这个键值对也叫做Entry,而每个Entry都是存储在数组当中,因 ...
- linux 重启和关机
重启命令有:reboot, shutdown -ry 0关机命令有:poweroff, shutdown -hy 0
- linux每日命令(9):cp命令
一.命令格式: cp [参数] source dest 或 cp [参数] source... directory 二.命令功能: 将源文件复制至目标文件,或将多个源文件复制至目标目录. 三. 命令参 ...
- Badboy教程
Badboy教程 摘自:Badboy-系列教程-资料整理 2016-11-30 1 界面介绍 2 录制 3 创建suites,tests,steps和Template 4 运行脚本 5 参数化 Add ...
- 【iCore1S 双核心板_FPGA】例程四:TCL脚本实验——配置引脚
代码包下载: 链接:http://pan.baidu.com/s/1o8G62im 密码:j0iq