poj 2000 Gold Coins(水题)
一、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.
二、题解
水题不多说!!值得祝贺,今天连克三道水题,水果30。
三、Java代码
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int n,i,j,sum,total;
while((n=cin.nextInt())!=0){
i=0;
sum=0;
j=0;
total=0;
while(sum<=n){
i++;
sum+=i;
}
j=n-(sum-i);
for(int m=1;m<i;m++){
total+=m*m;
}
total=total+j*i;
System.out.println(n+" "+total);
}
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
poj 2000 Gold Coins(水题)的更多相关文章
- OpenJudge/Poj 2000 Gold Coins
1.链接地址: http://bailian.openjudge.cn/practice/2000 http://poj.org/problem?id=2000 2.题目: 总Time Limit: ...
- poj 2000 Gold Coins
题目链接:http://poj.org/problem?id=2000 题目大意:求N天得到多少个金币,第一天得到1个,第二.三天得到2个,第四.五.六天得到3个....以此类推,得到第N天的金币数. ...
- POJ 1488 Tex Quotes --- 水题
POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...
- POJ 3641 Oulipo KMP 水题
http://poj.org/problem?id=3461 直接KMP就好.水题 #include<cstdio> #include<cstring> const int M ...
- poj 1006:Biorhythms(水题,经典题,中国剩余定理)
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 110991 Accepted: 34541 Des ...
- poj 1002:487-3279(水题,提高题 / hash)
487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 236746 Accepted: 41288 Descr ...
- poj 1003:Hangover(水题,数学模拟)
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 99450 Accepted: 48213 Descri ...
- poj 2105 IP Address(水题)
一.Description Suppose you are reading byte streams from any device, representing IP addresses. Your ...
- POJ 2365【YY水题】
题目链接:POJ 2365 Rope Rope Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7488 Accepted ...
随机推荐
- iOS 开发与H5交互(JavaScriptCore框架的使用)
现在的iOS项目中嵌入了越来越多的Web界面,当然是为了方便,那么为了迎合这一趋势,作为iOS开发程序员,我们必须要了解怎么样用OC去和这些Web界面进行交互.这里介绍的是JavaScriptCore ...
- 深入理解ByteBuffer(转)
转:http://blog.csdn.net/workformywork/article/details/26699345?utm_source=tuicool&utm_medium=refe ...
- R语言图形base系统(一)
一般R作图有三大绘图系统:base系统.ggplot2绘图系统.lattice绘图系统. 本篇主要介绍base系统绘图时的图形参数.一般用plot()函数来完成.在R中,若 ...
- C语言程序设计50例(经典收藏)之1
题目:有1.2.3.4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? 程序分析:可填在百位.十位.个位的数字都是1.2.3.4.组成所有的排列后再去 掉不满足条件的排列. #includ ...
- [原创]关于在CentOS 7.0 下 安装nfs ,遇见 Transaction check error问题的解决
今天小弟的同学在使用阿里云的服务器安装nfs的时候,出现了一下问题 Transaction check error: file /usr/lib/systemd/system/blk-availabi ...
- _CRT_SECURE_NO_WARNINGS
在新版编程器的编译过程中我们常常会遇到一些过时或者不安全的函数 举一个简单的例子: 很多带"_s"后缀的函数是为了让原版函数更安全,传入一个和参数有关的大小值,避免引用到不存在的元 ...
- hbase shell-ddl(表定义指令)
hbase表定义指令详细解说篇 1. alter, alter_async, alter_status 2. create 3. describe (可以简写成'desc') 显示某张表的结构情况 ...
- Ubuntu14 下安装jdk1.8
1.oracle官网下载jdk-8u45-linux-i586.gz 此为32位 2.放在任意目录下,如/home/hongxf 3.直接解压该文件 sudo tar -xvf jdk-8u45-li ...
- SrpingCloud 之SrpingCloud config分布式配置中心搭建
1.搭建git环境 目的:持久化存储配置文件信息 采用码云 创建后 继续创建文件夹 用来区分不同的项目 下面就是git上存放配置文件了.环境的区分 dev sit pre prd 开发 ...
- Docker-Mac安装
1. 下载安装包2. 安装3. 运行,允许docker获得系统权限,它需要将Mac网卡链接至Docker app.4. 验证 打开terminaldocker versionFengZhendeMac ...