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 ...
随机推荐
- spring mvc注解和spring boot注解
1 spring mvc和spring boot之间的关系 spring boot包含spring mvc.所以,spring mvc的注解在spring boot总都是可以用的吗? spring b ...
- 我的Android进阶之旅------>Android中的布局优化 include、merge 、ViewStub
1.如何重用布局文件? 可以使用<include>标签引用其他的布局文件,并用android:id属性覆盖被引用布局文件中顶层节点的android:id属性值.代码如下: <!--引 ...
- MySql四种隔离级别
什么是事务 事务是应用程序中一系列严密的操作,所有操作必须成功完成,否则在每个操作中所作的所有更改都会被撤消.也就是事务具有原子性,一个事务中的一系列的操作要么全部成功,要么一个都不做. 事务的结束有 ...
- goland中引用包
首先在工程目录下新建三个目录:bin, pkg,src Bin文件夹是放置编译后的exe文件 Pkg文件夹是放置包生成后的.a文件 Src文件夹是放置包文件的地方 工程组织目录如下,在src中有tes ...
- java基础入门之数组排序冒泡法
public class ArrayTest03{ /* Name:数组排序,冒泡法 Power by :Stuart Date:2015-4-23*/ public static void main ...
- CALL TRANSFORMATION 的方法生成XML文件
*&---------------------------------------------------------------------**& Report Z_BARRY_X ...
- ABAP制作密码输入框
[转自 http://blog.csdn.net/saphome/article/details/6956911] 这几天做一个系统维护的程序,需要用户输入用户名和密码登录.可怎样实现输入密码显示星号 ...
- 牛客小白月赛1 C 分元宵【快速幂】
题目链接 https://www.nowcoder.com/acm/contest/85/C 思路 有 A 种 元宵馅,B 种元宵皮 所以 我们可以认为 有Q = A * B 种 元宵 有 C 张桌子 ...
- 【LeetCode】【数组归并】Merge k Sorted Lists
描述 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity ...
- FHQ_treap
上个月还在舔\(splay\):\(FHQ-treap\)太好打了吧真香 前言 还是建议先把\(splay\)学好再看,讲得会比较粗略(但该有的不会少),或者左转其他文章 \(FHQ-treap\)是 ...