문제

링크

풀이

#include <iostream>
#define MOD 1000000007
using namespace std;
 
long long power(long long base, long long exp) {
  long long ret = 1;
  while (exp) {
    if (exp & 1) ret = ret * base % MOD;
    base = base * base % MOD;
    exp >>= 1;
  }
  return ret;
}
 
void solve(void) {
  int n, x; cin >> n >> x;
 
  long long ans = 0;
  for (int i=0; i<=n; i++) {
    long long a, b; cin >> a >> b;
    ans = (ans + a * power(x, b)) % MOD;
  }
  cout << ans;
}
 
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
 
  solve();
  return 0;
}