给定某数字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. Quartz.NET简介及入门指南

    Quartz.NET简介 Quartz.NET是一个功能完备的开源调度系统,从最小的应用到大规模的企业系统皆可适用. Quartz.NET是一个纯净的用C#语言编写的.NET类库,是对非常流行的JAV ...

  2. GATK--使用转载

    http://blog.sciencenet.cn/blog-1469385-819498.html 文章目录 一.准备工作 二.流程概览 三.流程 首先说说GATK可以做什么.它主要用于从seque ...

  3. python pandas demo

    1. import pandas as pd web_stats = {,,,,,], ,,,,,], ,,,,,]} df = pd.DataFrame(web_stats) print(df.he ...

  4. python 删除元组元素

    #create a tuple tuplex = "w", "j" ,"c", "e" print(tuplex) #t ...

  5. DEV-C++设置C++11标准

    DEV-C++默认的标准是C++98,改成C++11的方法如下: Tools -> Compiler Options -> Setting -> Code Generation -& ...

  6. jquery zTree异步加载的例子

    下面是使用zTree异步加载的一个例子: 1)初始化树的时候是ajax请求,返回nodes列表来初始化树的:如果一开始就异步的话,$.fn.zTree.init($("#zTree" ...

  7. Linux忘记root登录密码解决方法

    有时候由于长时间米有登录linux系统,等需要用的时候突然忘记root密码,怎么办?下面简单介绍解决方法. redhat 和 centos 6.5 可以,7.0以上未测 在系统重启后,不停地按”e”键 ...

  8. Oracle数据库system用户忘记了密码怎么办

    1.在运行里面输入cmd调出dos窗口,然后在dos窗口中输入sqlplus /nolog 如:D:\oracle\ora92\bin>sqlplus /nolog 2.输入连接命令 如:SQL ...

  9. Linux中查看各文件夹大小(扫盘)

    df -h ./ du -hs ./ du -h /ifs4/BC_RD/USER/lizhixin/my_project/human_chr22 | grep [[:digit:]+]G du [- ...

  10. 12月21日 简单理解Active Recore Callback, destroy_all和delete_all的区别。豆知识(alias),语言学习法(4核心)

    destroy_all and delete_all Destroy the records by instantiating each record and calling its #destroy ...