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 ...
随机推荐
- ConcurrentLinkedQueue代码解析
原因:学习ConcurrentLinkedQueue是看到akka框架的默认邮箱是使用ConcurrentLinkedQueue实现的. 1. ConcurrentLinkedQueue在java.u ...
- NIO-新的io操作方式
1.BIO带来的挑战 BIO即阻塞IO,不管是磁盘IO,还是网络IO,数据在写入OutputStream或者从InputStream读取时都有可能发生阻塞,一旦有阻塞,当前线程将会被挂起,即线程进入非 ...
- What is `^M` and how do I get rid of it?
When I open the file in vim, I am seeing strange ^M characters. Unfortunately, the world's favorite ...
- 【asp.net core】Publish to a Linux-Ubuntu 14.04 Server Production Environment
Submary 又升级了,目录结构有变化了 . project.json and Visual Studio 2015 with .NET Core On March 7, 2017, the .NE ...
- 使用Ubuntu
一.ubuntu把文件夹名称改为中文 vim ~/.config/user-dirs.dirs 修改文件内容为: XDG_DESKTOP_DIR="$HOME/Desktop" X ...
- redis 连接 docker容器 6379端口失败
redis部署在docker容器中Could not connect to Redis 容器内redis-cli是可以直接连上的,但是在另一台服务器上就不能用外网ip来连了 虽然我创建redis容器时 ...
- 物联网架构成长之路(22)-Docker练习之Etcd服务搭建
0. 前言 时隔多日,前段时间忙完一个可有可无的项目后,又进入摸鱼时间,没有办法,非互联网公司,就是闲得蛋疼.又开始了自学之路.以前入门过Docker,然后又很久没有看了,最近重新看了一下,推荐一下这 ...
- ①Android NuPlayer播放框架
[时间:2016-09] [状态:Open] [关键词:android,nuplayer,开源播放器,播放框架,nuplayerdriver] 0 NuPlayer简介 Android2.3时引入流媒 ...
- Python爬取金山词霸每日一句,存储到MySQL中
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/7/3 20:25 # @Author : baoshan # @Site : ...
- redis竞汰数据同步问题解决
Redis 面试的时候遇到过问Redis是如何解决“竞态条件”的,相关知识点总结一下. 乐观锁 所谓竞态条件,举个例子,一个代表点击数的数值hitcount,每个客户点击一次则+1. 没有事务的时候, ...