結果
| 問題 | No.148 試験監督(3) |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-10-16 20:48:52 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 1,191 bytes |
| 記録 | |
| コンパイル時間 | 2,561 ms |
| コンパイル使用メモリ | 333,608 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-10-16 20:49:06 |
| 合計ジャッジ時間 | 11,655 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 11 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
const int64 MOD = 1'000'000'007LL;
// ????????? m ??????? C <= 10^10000
int64 modStr(const string& s, int64 m) {
int64 r = 0;
for (char c : s) r = (r * 10 + (c - '0')) % m;
return r;
}
int64 solve(const string& Cs, const string& Ps) {
int64 cMod = modStr(Cs, MOD); // ??? C mod M
int64 pMod = modStr(Ps, MOD); // P mod M?P ??????
if (pMod == 0 && Ps != "0") { // P ? M ???? P>0 => P! ? 0
// ?????? P >= MOD ?? 0????????
}
// ????? P >= MOD
bool pBig = (Ps.size() > 10) || (Ps.size() == 10 && Ps >= "1000000007");
if (pBig) return 0;
int64 P = pMod;
if (P == 0) return 1; // ???
int64 x0 = (cMod - P + 1) % MOD;
if (x0 < 0) x0 += MOD;
if (x0 < P) return 0; // ?? "???" ???
int64 ans = 1;
for (int64 i = 0; i < P; ++i) // ??? (x0)_P
ans = (int64)((__int128)ans * (x0 - i) % MOD);
return ans;
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int T; cin >> T;
while (T--) { string C, P; cin >> C >> P; cout << solve(C, P) << '\n'; }
}
vjudge1