zoj 2345 Gold Coins
2012-03-31 12:40
316 查看
//这题主要是找一下规律就可以了: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; } }
相关文章推荐
- zoj 2345 Gold Coins
- zoj 2345 Gold Coins
- ZOJ 2345 Gold Coins
- zoj 2345 Gold Coins
- ZOJ-2345
- zoj2345
- zoj 2345
- zoj 3008 Gold Coins
- ZOJ 2345 国王金币数
- 2345_Gold Coins(输入分多个块,每个块中有多行,每个输入块之间有空格,但最后没有空格)
- ZOJ_Requirements
- ZOJ-1201
- ZOJ 3211 Dream City
- zoj 3529 Nim博弈
- ZOJ Magic Cube 2477
- [水题]zoj 1362
- poj 3308 zoj 2874 Paratroopers(最小割)
- ZOJ-3878
- zoj 1813
- ZOJ-1494