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 ...
随机推荐
- JAVA消息服务JMS规范及原理详解
JAVA消息服务JMS规范及原理详解 一.简介 JMS即Java消息服务(Java Message Service)应用程序接口,是一个Java平台中关于面向消息中间件(MOM)的API,用于在两个应 ...
- IDependency自动注册autofac
ContainerBuilder builder = new ContainerBuilder(); builder.RegisterGeneric(typeof(Repository<,> ...
- chromium 使用 flash
这又是个月经问题,几乎重装一次系统就得在搞一次. 1. chromium 使用的 flash 下载 https://get.adobe.com/cn/flashplayer/otherversions ...
- Shell脚本编程实战一:创建按天备份的脚本工具
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/8241256.html 一:准备工作:创建归档目录 与 归档配置文件 归档目录:创建一个仓库目录,专门用于存放 ...
- 【MySQL】玩转触发器、监听器
1.触发器是一个特殊的存储过程,不同的是存储过程要用CALL来调用,而触发器不需要使用CALL. 创建触发器 语法如下: CREATE TRIGGER trigger_name trigger_tim ...
- JAVA 自定义注解在自动化测试中的使用
在UI自动化测试中,相信很多人都喜欢用所谓的PO模式,其中的P,也就是page的意思,于是乎,在脚本里,或者在其它的page里,会要new很多的page对象,这样很麻烦,前面我们也讲到了注解的使用,很 ...
- JEECG中表单提交的中断
JEECG平台中基于form表单封装了<t:formvalid>标签,对应实现的类为FormValidationTag.java文件. 很多时候在正式向后台提交数据前想要做判断处理,若通过 ...
- Atitit.pagging 翻页功能解决方案专题 与 目录大纲 v3 r44.docx
Atitit.pagging 翻页功能解决方案专题 与 目录大纲 v3 r44.docx 1.1. 翻页的重要意义1 1.2. Dep废弃文档 paip.js翻页分页pageing组件.txt1 ...
- 【iCore4 双核心板_ARM】例程十五:USB_CDC实验——高速数据传输
实验方法: 1.安装USB CDC驱动,驱动安装方法参考例程包中安装方法文档. 2.将跳线冒跳至USB_OTG,通过Micro USB 线将iCore4 USB-OTG接口与电脑相连. 3.打开上位机 ...
- ubuntu GCC 版本切换
(1) 查看gcc以及g++的版本 gcc -v g++ -v star@ai:~ $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_L ...