Hackerrank Ad Infinitum - Math Programming Contest March'14 Summing the N series editorial: https://www.hackerrank.com/blog/infinitum-mar14-summing-the-n-series
Hackerrank Ad Infinitum - Math Programming Contest March'14 Summing the N series solution: http://ideone.com/d12qbF
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
long long int r, n, t;
const int md=1e9+7;
scanf("%lld", &t);
while(t--) {
scanf("%lld", &n);
n%=md;
r=(n*n)%md;
printf("%lld\n", r);
}
return 0;
}
note: i dont know why pow(n, 2) did not work. i asked a question regarding this on forum: https://www.hackerrank.com/contests/infinitum-mar14/challenges/summing-the-n-series/forum/questions/5293
No comments:
Post a Comment