输入格式:
输入在一行中给出正整数n(≤10)。
输出格式:
按照格式“result = 计算结果”输出。
输入样例:
5
输出样例:
result = 62
代码长度限制 16 KB
时间限制 400 ms
内存限制 64 MB
#include<stdio.h>
#include<math.h>
main(){
int n,sum=0,i=0;
scanf("%d",&n);
for(i=1;i<=n;i++) sum+=pow(2,i);
printf("result = %dn",sum);
}
最后
以上就是大方朋友最近收集整理的关于PTA R7-2 求幂之和的全部内容,更多相关PTA内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复