码迷,mamicode.com
首页 > 其他好文 > 详细

poj2000---和1969一样的模板

时间:2015-05-27 00:46:42      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int d;
    while(scanf("%d",&d)!=EOF)
    {
        int k=1,s=0,totgol=0,totday=0;
        int i;
        if(d==0)
            break;
        while(1)
        {
            s+=k;
            if(s>=d)
            {
                for(i=1;i<k;i++)
                {
                    totgol+=i*i;
                    totday+=i;
                }
                totgol+=(d-totday)*k;
                printf("%d %d\n",d,totgol);
                break;
            }
            k++;
        }
    }
    return 0;
}

 

poj2000---和1969一样的模板

标签:

原文地址:http://www.cnblogs.com/gabygoole/p/4532063.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!