답안 #106321

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106321 2019-04-17T21:14:13 Z xiaowuc1 Σ (kriii4_P2) C++14
100 / 100
9 ms 640 KB
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef vector<vector<ll>> matrix;

ll modpow(ll b, ll e, ll m) {
  ll r = 1;
  b %= m;
  while(e) {
    if(e%2) {
      r*=b;
      r%=m;
    }
    b*=b;
    b%=m;
    e/=2;
  }
  return r;
}
void solve() {
  int n;
  cin >> n;
  ll ret = 0;
  while(n--) {
    int a, b;
    cin >> a >> b;
    ret += b * modpow(a, 1e9 + 5, 1e9+7);
    ret %= (ll)1e9+7;
  }
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
	/*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
	*/
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 640 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 9 ms 512 KB Output is correct
5 Correct 9 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 6 ms 512 KB Output is correct
11 Correct 7 ms 512 KB Output is correct
12 Correct 7 ms 512 KB Output is correct
13 Correct 6 ms 512 KB Output is correct
14 Correct 7 ms 512 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 6 ms 512 KB Output is correct
17 Correct 7 ms 572 KB Output is correct
18 Correct 7 ms 512 KB Output is correct
19 Correct 6 ms 512 KB Output is correct
20 Correct 6 ms 512 KB Output is correct