给定某数字A(1≤A≤9)以及非负整数N(0≤N≤100000),求数列之和S=A+AA+AAA+⋯+AA⋯A(N个A)。例如A=1, N=3时,S=1+11+111=123

输入格式:

输入数字A与非负整数N。

输出格式:

输出其N项数列之和S的值。

输入样例:

1 3

输出样例:

123

 #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<vector>
using namespace std; int main()
{
int a,n;
scanf("%d%d",&a,&n);
int i,j=,last=;
int b[];
for(i=n;i>=;i--)
{
b[j++]=(i*a+last)%;
last=(i*a+last)/;
}
if(last>)
printf("%d",last);
for(i=j-;i>=;i--)
printf("%d",b[i]);
if(n==)
printf("");//别忘啦
printf("\n");
return ;
}

PAT 数列求和-加强版   (20分)(简单模拟)的更多相关文章

  1. [PAT]数列求和(20)

    #include "stdio.h" #include "malloc.h" #include "math.h" void calc(int ...

  2. PAT  说反话-加强版   (20分)

    给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出. 输入格式: 测试输入包含一个测试用例,在一行内给出总长度不超过500 000的字符串.字符串由若干单词和若干空格组成,其中单词是由英文字母 ...

  3. #020PAT 没整明白的题L1-009 N个数求和 (20 分)

    后面的测试点过不去,两个错误一个超时. 目前未解决   L1-009 N个数求和 (20 分)   本题的要求很简单,就是求N个数字的和.麻烦的是,这些数字是以有理数分子/分母的形式给出的,你输出的和 ...

  4. PAT 甲级 1077 Kuchiguse (20 分)(简单,找最大相同后缀)

    1077 Kuchiguse (20 分)   The Japanese language is notorious for its sentence ending particles. Person ...

  5. PAT 甲级 1035 Password (20 分)(简单题)

    1035 Password (20 分)   To prepare for PAT, the judge sometimes has to generate random passwords for ...

  6. PAT 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)

    1144 The Missing Number (20 分)   Given N integers, you are supposed to find the smallest positive in ...

  7. pat 1035 Password(20 分)

    1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the ...

  8. PAT 1088 三人行(20 分)(暴力破解+流程分析)

    1088 三人行(20 分) 子曰:"三人行,必有我师焉.择其善者而从之,其不善者而改之." 本题给定甲.乙.丙三个人的能力值关系为:甲的能力值确定是 2 位正整数:把甲的能力值的 ...

  9. pat 1077 Kuchiguse(20 分) (字典树)

    1077 Kuchiguse(20 分) The Japanese language is notorious for its sentence ending particles. Personal ...

随机推荐

  1. 下载liteide

    https://github.com/visualfc/liteide/releases/tag/x35.3

  2. python ros 关闭节点

    def myhook(): print "shutdown time!" rospy.on_shutdown(myhook) 或 rospy.signal_shutdown(rea ...

  3. ubuntu14.04, keyboard shortcuts

  4. SetParent

    1.http://bbs.csdn.net/topics/390672855 该帖子中 第15楼: “ MSDN里面说了:if hWndNewParent is not NULL and the wi ...

  5. Qt532_字符编码转换

    1.测试代码: // http://blog.csdn.net/changsheng230/article/details/6588447 QString str = QString::fromLoc ...

  6. VSS_01

    1.设置 工作目录 右击 CSDRGis --> Set Working Folder.. --> D:\CSDRGis 2.下载 源码 右击 CSDRGis --> Get Las ...

  7. nginx反向代理和正向代理,优缺点

    http://blog.csdn.net/lishaojun0115/article/details/53200629 nginx反向代理代理的是服务器,正向代理代理的是客户端, 反向代理是客户点发送 ...

  8. Java的JDK和JRE

    Java的JDK和JRE 1.计算机交互方式 图形化界面(Graphical User Interface GUI) 命令行方式(Command Line Interface CLI) 2.Java语 ...

  9. English trip -- VC(情景课)4 B Parts of the body 身体部位

    xu言: ... Words eye  读音同 I     眼睛 nose 鼻子 ear   耳朵 tooth  牙齿 mouth  嘴 hair 头发 eyebrow  眉毛 cheek  脸颊 n ...

  10. English trip -- Phonics 1 ar

    Xu言: Learning is not a happy thing, but happiness always comes with learning...    - loki.valentine ...