1 条题解
-
0
C :
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> int main() { // freopen("in","r",stdin); // freopen("out","w",stdout); int a,n; long total; long x; int i = 0; while(scanf("%d%d",&a,&n)!=EOF) { x=1; total=0; for(i=0; i<n; i++) { x *= a; total += x; } total = x*2 - total; printf("%d\n",total); } return 0; }
C++ :
#include<stdio.h> #include<math.h> int main() { int a,n,sum,j; while(scanf("%d%d",&a,&n)!=EOF) { sum=pow(a,n); for(j=n-1;j>0;j--) { sum=sum-pow(a,j); } printf("%d\n",sum); } return 0; }
- 1
信息
- ID
- 280
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者