当前位置:网站首页>Zzuli:1052 sum of sequence 4

Zzuli:1052 sum of sequence 4

2022-07-03 14:34:00 Snake_____

Title Description

Input n and a, seek a+aa+aaa+…aa…a(n individual a), As if n=3,a=2 when ,2+22+222 As the result of the 246

Input

Contains two integers ,n and a, The meaning is as above , You can assume that n and a All are less than 10 Non-negative integer

Output

Before output n Xiang He , Take a line alone

The sample input  Copy

3 2

Sample output  Copy

246
#include <stdio.h>
int main()
{
	int n,a,i,x=0,sum=0;
	scanf("%d%d",&n,&a);
	for(i=1;i<=n;i++)
	{
		x=x+a;
		sum=sum+x;
		a=a*10;
	}
	printf("%d",sum);
	return 0;
}

原网站

版权声明
本文为[Snake_____]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202150513526223.html