zoj 2345 Gold Coins

原创 2012年03月31日 12:40:42
//这题主要是找一下规律就可以了:1^2 + 2^2 + 3^2 + ..... + n^2
#include "iostream"
#include "memory.h"
using namespace std;

int main()
{
	int testcase, i, days, coins, temp, remain;
	cin >> testcase;
	while (testcase--)
	{
		while (cin >> days && days)
		{
			coins = 0;
			temp = 1;
			for (i = 1; temp <= days; i++, temp += i)
			{
				coins += i * i;
			}
			remain = (days - (temp-i)) * i;
			coins += remain;
			cout << days << " " << coins << endl;
		}
		if (testcase)
			cout << endl;
	}
}

Gold Coins

Description The king pays his loyal knight in gold coins. On the first day of his service, the kn...

POJ-2000 Gold Coins

Gold Coins Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21914   Ac...
  • MIKASA3
  • MIKASA3
  • 2015年08月07日 20:00
  • 624

[ACM] POJ 2000 Gold Coins

Gold Coins Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 20913   Ac...

杭电2410Baskets_Of_Gold_Coins

/* * 题目: Baskets_Of_Gold_Coins(篮子里的金币) 翻译:给你N个篮子装金币。也就是说篮子的数量是从1到N个,在所有篮子中除了一个篮子,每个普通篮子里金币的重量都是 w...

Free FIFA 15 ps4 ultimate team coins Giveaway for Everyone Liking Gold4fans Facebook

What Ruben seems 100% Winning Rate: Get Free FIFA 15 coins by clicking "Like" on Gold4fans faceb...

YT15-HDU-Harry's parents had left him a lot of gold coins

Problem Description   Famous Harry Potter,who seemd to be a normal and poor boy,is actually a wiza...

POJ 2000 Gold Coins

Gold Coins Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 22762   Ac...
  • LZK1997
  • LZK1997
  • 2016年11月12日 17:35
  • 224

poj 2000 Gold Coins(水题)

一、Description The king pays his loyal knight in gold coins. On the first day of his service, the kni...

HDOJ 2401 Baskets of Gold Coins(数学,等差数列求和)

Baskets of Gold Coins Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java...

POJ2000浅析------Gold Coins

Gold Coins Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17568   Ac...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:zoj 2345 Gold Coins
举报原因:
原因补充:

(最多只允许输入30个字)