整数求和
来源:互联网 发布:淘宝商城女童鞋 编辑:程序博客网 时间:2024/06/05 10:13
Description
输入两个整数a和n,求 a + aa + aaa +…+ aa…a (注:n个a) 之和。例如输入2和3,输出246(因为2 + 22 + 222 = 246)。
本题所给测试数据的计算结果不超出unsigned long的表示范围。
Input
输入有多行,每一行是两个整数。第一个是上述的a,第二个是上述的n。
a不是负数,n > 0 。
Output
对应输入的每行,单独输出一行求和的结果。
Sample Input
2 3
9 4
Sample Output
246
11106
#include <stdio.h>#include <math.h>int main(void){ double a,n,j,sum=0,temp=1,temp1=0; while (scanf("%lf %lf",&a,&n)!=EOF) { if(a>=0&&n>0) { for(j=0;j<n;j++) { temp=pow(10,j); temp1=temp+temp1; sum=sum+temp1; } printf("%.0f\n",sum*a); sum=0; temp1=0; } } return 0;}
阅读全文
0 0
- 整数求和
- 整数求和
- 整数求和
- 整数求和
- 整数求和
- 大整数求和
- ;整数数组求和
- noj0001 - 整数求和
- NOJ-整数求和
- 大整数求和
- 汇编多整数求和
- 大整数求和
- acm_整数求和
- PHP大整数求和
- 两个整数之间所有整数求和
- 输入两个大整数,求和
- 1090 简单整数数列求和
- 1107 一组整数求和(1)
- Eclipse svn提交代码的一般步骤(对比、解决冲突、更新、提交)
- ViewPager学习
- MongoDB第一课,shell命令下的增删改查
- SSH整合
- Android学习 ——SystemUIService之StorageNotification分析
- 整数求和
- Node.js环境下对MongoDB实现查,插,分页功能
- 习题6.7
- 配置Canvas为全屏时,无滚动条
- android string.xml里空格表示
- 常用的转义字符表
- M
- android okhttp3框架使用
- pc端和手机端禁用滚动条