QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#279553 | #6956. Many Topological Problems | IsaacMoris# | AC ✓ | 50ms | 3604kb | C++14 | 705b | 2023-12-08 21:10:46 | 2023-12-08 21:10:47 |
Judging History
answer
#include<iostream>
#include <bits/stdc++.h>
#define ld long double
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 30, mod = 1e9+7;
void doWork() {
int n, k;
cin >> n >> k;
int ans = 1;
for (int i = 1; i <= n; i++) {
ans = 1ll * ans * i % mod;
if (i - 1 <= k) {
ans = 1ll * ans * max(1, i - 1) % mod;
} else {
ans = 1ll * ans * k % mod;
}
}
cout << ans << "\n";
}
int main() {
IO
int t = 1;
cin >> t;
for (int i = 1; i <= t; i++) {
// cout << "Case #" << i << ": ";
doWork();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 50ms
memory: 3604kb
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