关闭

POJ 2000 Gold Coins(水~)

479人阅读 评论(0) 收藏 举报
分类:

Description
第一天得到一个,第二第三天得到分别得到两个,第三第四第五天分别得到三个以此类推,n天总共得到多少金币
1金币 1
2金币 2 3
3金币 4 5 6
4金币 7 8 9 1 0
5金币 11 12 13 14 15
…………………………………………
Input
多组输入,每组用例一个整数n代表查询天数,以n=0结束输入
Output
对于每组用例,输出第n天后总共得到多少金币
Sample Input
10
6
7
11
15
16
100
10000
1000
21
22
0
Sample Output
10 30
6 14
7 18
11 35
15 55
16 61
100 945
10000 942820
1000 29820
21 91
22 98
Solution
简单的数列求和
Code

#include<stdio.h>
int main()
{
    int i,j,n,m,day;
    while(scanf("%d",&n)&&n)
    {
        m=day=0;
        for(i=1;;i++)
        {
            if(day+i<n)
            {
                m+=i*i;
                day+=i;
            }
            else
                break;
        }
        m+=i*(n-day);
        printf("%d %d\n",n,m);
    }
}
0
0
查看评论

【水】POJ 2000——Gold Coins

来源:点击打开链接 水过……没法再水的题,会用数组就行了。 #include #include #include using namespace std; int caler[10001]; void init() { memset(caler,0,sizeof(caler));...
  • mig_davidli
  • mig_davidli
  • 2013-09-23 19:30
  • 1238

POJ 2000 - Gold Coins

Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 20719   Accepted: 12964 Description Th...
  • u011521976
  • u011521976
  • 2014-05-05 19:35
  • 251

poj 2000 Gold Coins

Gold Coins Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 16229 Accepted: 10172 Description The king pays...
  • wwk0125
  • wwk0125
  • 2014-03-24 12:05
  • 331

Gold Coins POJ 2000

Description The king pays his loyal knight in gold coins. On the first day of his service, the knight receives one gold coin. On each of the next two...
  • Sunmh_AC
  • Sunmh_AC
  • 2015-08-18 08:52
  • 249

POJ 2000 Gold Coins

Gold Coins Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 20796   Accepted: 13014 Description The ...
  • u014492513
  • u014492513
  • 2014-05-28 12:32
  • 455

POJ - 2000 Gold Coins

题目地址:POJ - 2000
  • Styx12
  • Styx12
  • 2017-11-18 23:02
  • 53

POJ 2000 Gold Coins

Description The king pays his loyal knight in gold coins. On the first day of his service, the knight receives one gold coin. On each of the next two...
  • llwwlql
  • llwwlql
  • 2015-09-13 19:20
  • 249

[2000]Gold Coins(水题)POJ

 Online Judge Problem Set Authors Online Contests User Web Board Home Page F.A.Qs Sta...
  • jiangyongy
  • jiangyongy
  • 2014-09-05 22:38
  • 265

OpenJudge/Poj 2000 Gold Coins

1.链接地址: http://bailian.openjudge.cn/practice/2000 http://poj.org/problem?id=2000 2.题目: 总Time Limit:1000msMemory Limit:65536kBDescriptionThe king p...
  • mobileliker163
  • mobileliker163
  • 2014-12-04 13:05
  • 238

POJ 2000 Gold Coins 简单模拟

Gold Coins Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21914   Accepted: 13732 Description T...
  • zp___waj
  • zp___waj
  • 2015-08-07 19:49
  • 418
    个人资料
    • 访问:555938次
    • 积分:24575
    • 等级:
    • 排名:第315名
    • 原创:1943篇
    • 转载:0篇
    • 译文:0篇
    • 评论:69条
    最新评论