2015年NEUACM一月月赛 C

问题 C: Sum?Sum!

时间限制: 1 Sec  内存限制: 128 MB
提交: 653  解决: 176
[ 提交][ 状态][ 讨论版]

题目描述

Kid want to learn math better.Now Kid know how to calculate the sum of 1 to n in a short time.But this time,he is given a much more difficult question——to calculate the sum of 1 to 10^n.Kid think for a long time——10^10 ms and then he solve the question successfully.

Do you know how to solve it ?

 

输入

The first line is a integer t(1<=t<=10),indicate the number of case.

For each t,there is a integer n(the meaning of n is in the above),0<=n<=10^4.

 

输出

For each case,just print the answer of the sum.

 

样例输入

1
1

样例输出

55

提示

 

 

 

 

思路:其实这是由规律的n=1的时候是55,n=2的时候5050,n=3  500500,n=4   50005000。。。。一直下去

PS注意n=0事为1

 

 

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int t,n,i;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        if(n==0)
        {
            printf("1\n");
            continue;
        }
        printf("5");
        for(i=0; i<n-1; i++)
        {
            printf("0");
        }
        printf("5");
        for(i=0; i<n-1; i++)
        {
            printf("0");
        }
        printf("\n");
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/Wing0624/p/4264444.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值