QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#715702 | #6956. Many Topological Problems | hejinming983282# | AC ✓ | 31ms | 11448kb | C++23 | 1.2kb | 2024-11-06 13:06:13 | 2024-11-06 13:06:14 |
Judging History
answer
// Author : hejinming2012
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define dbg(x) cout << #x " = " << (x) << endl
#define quickio ios::sync_with_stdio(false);
#define quickin cin.tie(0);
#define quickout cout.tie(0);
#define mod 1000000007
#define maxn 1000005
using namespace std;
inline int read() {
int now = 0, nev = 1; char c = getchar();
while(c < '0' || c > '9') { if(c == '-') nev = -1; c = getchar(); }
while(c >= '0' && c <= '9') { now = (now << 1) + (now << 3) + (c & 15); c = getchar(); }
return now * nev;
}
void write(int x) {
if(x < 0) putchar('-'), x = -x;
if(x > 9) write(x / 10);
putchar(x % 10 + '0');
}
int fac[maxn];
int qpow(int x, int y) {
int res = 1;
while(y) {
if(y & 1) res = res * x % mod;
x = x * x % mod, y >>= 1;
}
return res;
}
signed main() {
quickio
quickin
quickout
fac[0] = 1;
for(int i = 1; i < maxn; i++)
fac[i] = fac[i - 1] * i % mod;
int T = read();
while(T--) {
int n = read(), k = read(), ans = 1;
for(int i = 2; i <= n; i++)
ans = ans * min(i - 1, k) % mod;
write(ans * fac[n] % mod), putchar(10);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 31ms
memory: 11448kb
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