QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#197782 | #6956. Many Topological Problems | PPP# | AC ✓ | 51ms | 3644kb | C++17 | 1.1kb | 2023-10-02 19:49:50 | 2023-10-02 19:49:50 |
Judging History
answer
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod = (int)1e9 + 7;
int mult(int a, int b) {
return (1LL * a * b) % mod;
}
int sum(int a, int b) {
int s = a + b;
if (s >= mod) s -= mod;
return s;
}
int pw(int a, int b) {
if (b == 0) return 1;
if (b & 1) return mult(a, pw(a, b - 1));
int res = pw(a, b / 2);
return mult(res, res);
}
int sub(int a, int b) {
int s = a - b;
if (s < 0) s += mod;
return s;
}
const int inv3 = pw(3, mod - 2);
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef DEBUG
freopen("input.txt", "r", stdin);
#endif
int tst;
cin >> tst;
while (tst--) {
int n, k;
cin >> n >> k;
int ans = 1;
for (int i = 1; i <= n; i++) {
ans = mult(ans, i);
if (i > 1) {
ans = mult(ans, min(i - 1, k));
}
}
cout << ans << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 51ms
memory: 3644kb
input:
10 1 1 700503 623646 939811 584922 752155 569391 348265 116258 839298 839298 800391 216447 150847 116426 370812 168588 1000000 407619
output:
1 972550684 617838838 561525568 470024873 910196299 782371500 133886363 868118624 262962652
result:
ok 10 lines