# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19417 |
2016-02-24T11:38:48 Z |
golala123 |
Σ (kriii4_P2) |
C++ |
|
32 ms |
1720 KB |
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
long long a ,b , total;
int t;
const int MOD = 1000000007;
int main(){
cin >> t;
while (t--){
cin >> b >> a;
int x = 1000000005;
long long ans = 1;
vector<long long> m;
vector< pair<int, int > > two;
long long temp = 1;
int i = 0;
m.push_back(b);
while (temp < MOD){
long long aa = 1;
aa = m[i] % MOD * m[i] % MOD;
aa %= MOD;
m.push_back(aa%MOD);
temp *= 2;
i++;
}
int j = 0;
while (x != 0){
if (x % 2 == 1)
two.push_back({ j, x % 2 });
x /= 2;
j++;
}
for (int i = 0; i < two.size(); i++){
if (two[i].second == 1){
ans = ans*m[two[i].first] % MOD;
ans %= MOD;
}
}
ans = a*ans % MOD;
total += ans;
total %= MOD;
}
cout << total;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1720 KB |
Output is correct |
2 |
Correct |
32 ms |
1720 KB |
Output is correct |
3 |
Correct |
32 ms |
1720 KB |
Output is correct |
4 |
Correct |
32 ms |
1720 KB |
Output is correct |
5 |
Correct |
32 ms |
1720 KB |
Output is correct |
6 |
Correct |
30 ms |
1720 KB |
Output is correct |
7 |
Correct |
30 ms |
1720 KB |
Output is correct |
8 |
Correct |
30 ms |
1720 KB |
Output is correct |
9 |
Correct |
32 ms |
1720 KB |
Output is correct |
10 |
Correct |
30 ms |
1720 KB |
Output is correct |
11 |
Correct |
30 ms |
1720 KB |
Output is correct |
12 |
Correct |
30 ms |
1720 KB |
Output is correct |
13 |
Correct |
27 ms |
1720 KB |
Output is correct |
14 |
Correct |
29 ms |
1720 KB |
Output is correct |
15 |
Correct |
29 ms |
1720 KB |
Output is correct |
16 |
Correct |
31 ms |
1720 KB |
Output is correct |
17 |
Correct |
30 ms |
1720 KB |
Output is correct |
18 |
Correct |
30 ms |
1720 KB |
Output is correct |
19 |
Correct |
24 ms |
1720 KB |
Output is correct |
20 |
Correct |
30 ms |
1720 KB |
Output is correct |