当前位置:网站首页>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

边栏推荐
- What does the expression > > 0 in JS mean
- MQ 消息丢失、重复、积压问题,如何解决?
- Using recursion and chain header interpolation to realize the group turnover of linked lists -- leetcode25 K group turnover linked lists
- Opencv macro definition
- 分布式限流 redission RRateLimiter 的使用及原理
- 动态规划问题(二)
- Application of Devops in Internet of things solutions
- Laravel8 middleware realizes simple permission control
- Real time data warehouse: Netease strictly selects the practice of real-time data warehouse based on Flink
- Advanced area of attack and defense world web masters ics-06
猜你喜欢

Event extraction and documentation (2008-2017)
![[applet project development -- JD mall] uni app commodity classification page (first)](/img/6c/5b92fc1f18d58e0fdf6f1896188fcd.png)
[applet project development -- JD mall] uni app commodity classification page (first)

Android studio connects to MySQL and completes simple login and registration functions
![[small bug diary] Navicat failed to connect to MySQL | MySQL service disappeared | mysqld installation failed (this application cannot run on your computer)](/img/ac/f63e370df72ace484a618cf946d4b7.png)
[small bug diary] Navicat failed to connect to MySQL | MySQL service disappeared | mysqld installation failed (this application cannot run on your computer)

MySQL的存储过程

MySQL stored procedure

DCAT in laravel_ Admin preliminary use record

MySql中的like和in走不走索引

Solution: direct local.Aar file dependencies are not supported when building an aar

Google browser, no installation required
随机推荐
Event extraction and documentation (2008-2017)
flyway的快速入门教程
Applet waterfall flow, upload pictures, simple use of maps
MySQL的存储过程
[microservice] Nacos cluster building and loading file configuration
动态规划问题(六)
Solution: direct local.Aar file dependencies are not supported when building an aar
Idea error running 'application' command line is too long solution
[micro services ~nacos] Nacos service providers and service consumers
MySql中的like和in走不走索引
Network traffic monitoring tool iftop
Plato farm is expected to further expand its ecosystem through elephant swap
递归/回溯刷题(中)
PHP语言基础知识(超详细)
动态规划问题(四)
centos7安装mysql8
Idea2021.2 installation and configuration (continuous update)
Locally connect to redis on Windows Server
Use hutool tool class to operate excel with more empty Sheet1
Laravel permission control