当前位置:网站首页>PTA (daily question) 7-72 calculate the cumulative sum
PTA (daily question) 7-72 calculate the cumulative sum
2022-07-29 00:22:00 【Little Deng programmer who can write bugs】
Enter two integers n and a, Sum up S=a+aa+aaa+…+aa…a(n individual a) It's worth .
for example , When n=5,a=2 when ,S=2+22+222+2222+22222=24690.
Input format :
There are multiple sets of test data , Processing to the end of the file . Enter two integers for each set of tests n and a(1≤n,a<10).
Output format :
For each group of tests , Output a+aa+aaa+…+aa…a(n individual a) It's worth .
sample input :
5 3
8 6
sample output :
37035
74074068
Code :
import math
try:
while True:
n, a = map(int,input().split())
result = 0
k = 0
for i in range(n):
k += a*int(math.pow(10, i))
result += k
print(result)
except EOFError:
pass
边栏推荐
- [micro services ~nacos] Nacos service providers and service consumers
- 【小程序项目开发 -- 京东商城】uni-app 商品分类页面(上)
- NPM replace the latest Taobao image
- Network traffic monitoring tool iftop
- Eye of depth (18) -- partial derivative
- Field injection is not recommended solution
- Locally connect to redis on Windows Server
- Leetcode61. rotating linked list
- Alibaba Code代码索引技术实践:为Code Review提供本地IDE的阅读体验
- vulnhub:Sar
猜你喜欢
Recursion / backtracking (Part 2)
Intelligent trash can (VII) -- Introduction and use of sg90 steering gear (Pico implementation of raspberry pie)
Network traffic monitoring tool iftop
时间序列统计分析
Okaleido ecological core equity Oka, all in fusion mining mode
Where is sandbox's confidence in rejecting meta's acquisition of meta universe leader sand?
MySQL stored procedure
MySQL事务(transaction) (有这篇就足够了..)
Attack and defense world web master advanced area php2
AutoCAD -- import excel tables into CAD and merge CAD
随机推荐
递归/回溯刷题(下)
The difference between {} and ${}
With this, your messages can't be monitored
1331. 数组序号转换 : 简单模拟题
Geth installation
How NAT configures address translation
SQL implementation merges multiple rows of records into one row
Where is sandbox's confidence in rejecting meta's acquisition of meta universe leader sand?
动态规划问题(六)
Applet verification code login
Servlet运行原理_API详解_请求响应构造进阶之路(Servlet_2)
Plato farm is expected to further expand its ecosystem through elephant swap
vulnhub:BTRSys2
Everything you have learned will come in handy at some point in your life (turn)
Feign call fails. JSON parse error illegal character ((ctrl-char, code 31)) only regular white space (R
What does the expression > > 0 in JS mean
Add build dependency error
【微服务~Nacos】Nacos服务提供者和服务消费者
Using recursion and chain header interpolation to realize the group turnover of linked lists -- leetcode25 K group turnover linked lists
AutoCAD -- import excel tables into CAD and merge CAD