Skip to content

Commit

Permalink
Merge pull request #156 from dnhuan/dnhuan-wait-for-it
Browse files Browse the repository at this point in the history
Create waitForIt.cpp - Doan Ngoc Huan
  • Loading branch information
TANIYA GUPTA authored Oct 17, 2018
2 parents fd5fa9b + f518574 commit fb3e411
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions SOLUTIONS/waitForIt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;
const long long mod = 10e9 + 7;
int T;

int main()
{
cin >> T;
while(T--){
long long res = 0, n, a, b;
cin >> a >> b >> n;
for(long long i = 1; i <= n; i++){
for(long long j = 1; j <= n; j++){
long long first = pow(a,i) - pow(b,i),
second = pow(a,j) - pow(b,j);
res = (res + __gcd( first , second )) % mod;
}
}
cout << res << endl;
}
return 0;
}

0 comments on commit fb3e411

Please sign in to comment.