zoukankan      html  css  js  c++  java
  • 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
    ");
                continue;
            }
            printf("5");
            for(i=0; i<n-1; i++)
            {
                printf("0");
            }
            printf("5");
            for(i=0; i<n-1; i++)
            {
                printf("0");
            }
            printf("
    ");
        }
        return 0;
    }
  • 相关阅读:
    微博深度学习平台架构和实践
    2020暑期学习
    2020春季学期个人课程总结
    人月神话阅读笔记03
    人月深化阅读笔记02
    第十六周学习总结
    人月神话阅读笔记01
    三分算法
    [SDOI2010]魔法猪学院
    【洛谷】NOIP2018原创模拟赛DAY1解题报告
  • 原文地址:https://www.cnblogs.com/Wing0624/p/4264444.html
Copyright © 2011-2022 走看看