fork download
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main(){
  4. int i,x,n,term,sign;
  5. i=1;
  6. term=1;
  7. sign=1;
  8. long long int sum=0;
  9. scanf("%d%d",&x,&n);
  10. while(i<=n){
  11. sum=sum+sign*pow(x,term);
  12. term+=2;
  13. sign=-sign;
  14. i++;
  15. }
  16. printf("%lld",sum);
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
-9223372036854775808