結果

問題 No.148 試験監督(3)
ユーザー koba-e964koba-e964
提出日時 2015-05-07 18:39:30
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,215 bytes
コンパイル時間 812 ms
コンパイル使用メモリ 88,500 KB
実行使用メモリ 11,908 KB
最終ジャッジ日時 2023-09-19 07:56:00
合計ジャッジ時間 5,781 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;

const ll mod = 1e9+7;

PI conv(const string &s) {
  ll a = 0;
  int over = 0;
  REP(i, 0, s.size()) {
    a *= 10;
    a += s[i] - '0';
    if (a >= mod) {
      over = 1;
    }
    a %= mod;
  }
  return PI((int)a, over);
}



int main(void){
  int t;
  cin >> t;
  REP(i, 0, t) {
    string c, p;
    cin >> c >> p;
    PI cc = conv(c), pc = conv(p);
    if (pc.second) {
      cout << 0 << endl;
      continue;
    }
    ll cq = cc.first, pq = pc.first;
    ll sum = 1;
    cq += mod - pq + 1;
    cq %= mod;
    REP(j, 0, pq) {
      sum *= (cq - j + mod);
      sum %= mod;
    }
    cout << sum << endl;
  }
  
}
0