POJ 2000
来源:互联网 发布:pkpm钢结构计算软件 编辑:程序博客网 时间:2024/05/16 11:58
题意:国王给骑士付工钱,第一天1枚金币,后面两天每天2枚,再后面三天每天3枚······
要求输入天数,输出骑士在这些天里获得的总钱数。
代码:
#include<iostream>
usingnamespace std;
intmain()
{
int data;
while(cin>>data,data)
{
int i,temp=0,money=0;
for(i=1;;i++)
{
temp+=i;
if(temp>=data)break;
money+=i*i;
}
money+=i*(data-temp+i);
cout<<data<<""<<money<<endl;
}
return 0;
}
using
int
{
}
- POJ 2000
- poj 2488
- POJ 3299
- poj 1905
- POJ 2485 Highways
- POj 1017 Packets
- poj 1020 搜索
- poj 3278 宽搜
- poj 1426 宽搜
- poj 1925 Spiderman
- poj 3259 Wormholes
- POJ 2160 BOX
- POJ 2190 ISBN
- poj 3299 humidex
- poj 2253 Frogger
- poj 2485 Highways
- poj 3041 Asteroids
- poj 数论 1845
- POJ 1862
- POJ 1906
- POJ 1922
- POJ 1929
- POJ 1969
- POJ 2000
- POJ 2005
- POJ 2017
- POJ 2070
- POJ 1931
- CSharpThinking
- POJ 1976
- 利用new定义二维数组,delete删除…
- POJ 2101