PAT 数列求和-加强版 (20分)(简单模拟)
给定某数字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分)(简单模拟)的更多相关文章
- [PAT]数列求和(20)
#include "stdio.h" #include "malloc.h" #include "math.h" void calc(int ...
- PAT 说反话-加强版 (20分)
给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出. 输入格式: 测试输入包含一个测试用例,在一行内给出总长度不超过500 000的字符串.字符串由若干单词和若干空格组成,其中单词是由英文字母 ...
- #020PAT 没整明白的题L1-009 N个数求和 (20 分)
后面的测试点过不去,两个错误一个超时. 目前未解决 L1-009 N个数求和 (20 分) 本题的要求很简单,就是求N个数字的和.麻烦的是,这些数字是以有理数分子/分母的形式给出的,你输出的和 ...
- PAT 甲级 1077 Kuchiguse (20 分)(简单,找最大相同后缀)
1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Person ...
- PAT 甲级 1035 Password (20 分)(简单题)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for ...
- PAT 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)
1144 The Missing Number (20 分) Given N integers, you are supposed to find the smallest positive in ...
- pat 1035 Password(20 分)
1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the ...
- PAT 1088 三人行(20 分)(暴力破解+流程分析)
1088 三人行(20 分) 子曰:"三人行,必有我师焉.择其善者而从之,其不善者而改之." 本题给定甲.乙.丙三个人的能力值关系为:甲的能力值确定是 2 位正整数:把甲的能力值的 ...
- pat 1077 Kuchiguse(20 分) (字典树)
1077 Kuchiguse(20 分) The Japanese language is notorious for its sentence ending particles. Personal ...
随机推荐
- React Native控件之Switch开关
这个组件很简单 主要有两个属性:开.关....呵呵哒,,, import React,{Component}from 'react'; import { AppRegistry, StyleSheet ...
- redis教程(The little redis book中文版)
许可证 <The Little Redis Book>是经由Attribution-NonCommercial 3.0 Unported license许可的,你不需要为此书付钱. 你可以 ...
- Springboot mybatis generate 自动生成实体类和Mapper
https://github.com/JasmineQian/SpringDemo_2019/tree/master/mybatis Springboot让java开发变得方便,Springboot中 ...
- 禁用表单元素 && 禁止选中
一.禁用表单元素 1.dom设置属性 disabled="disabled" || disabled=true 2.css样式(高版本浏览器) pointer-events:non ...
- tp3.x和tp 5的区别
由于TP5.0是一个全新的颠覆重构版本,所以现在面试很多面试官喜欢问TP3.2和TP5之间的区别,那他们之间到底有哪些区别呢?一.目录 TP5目录 二.需要摒弃的 3.X 旧思想 模型的变动 ...
- Codeforces 535C - Tavas and Karafs
535C - Tavas and Karafs 思路:对于满足条件的r,max(hl ,hl+1 ,hl+2 ,......,hr )<=t(也就是hr<=t)且∑hi<=t*m.所 ...
- 如何对Visibility属性进行动画(XMAL /CS)
更新:2007 年 11 月 对指定 Duration 内的一组 KeyFrames 中的 Object 属性值进行动画处理. 命名空间: System.Windows.Media.Animatio ...
- English trip -- VC(情景课)1 A Get ready
Meet your classmates 见见你的同学 Look at the picture. What do you see? 看图片.你看到了什么? calendar 日历 bookcase ...
- 20170612xlVBA含方框文档填表
Sub mainProc() Application.ScreenUpdating = False Application.DisplayAlerts = wdAlertsNone 'Dim xlAp ...
- hdu2328 kmp
Beside other services, ACM helps companies to clearly state their “corporate identity”, which includ ...