QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#715702#6956. Many Topological Problemshejinming983282#AC ✓31ms11448kbC++231.2kb2024-11-06 13:06:132024-11-06 13:06:14

Judging History

你现在查看的是最新测评结果

  • [2024-11-06 13:06:14]
  • 评测
  • 测评结果:AC
  • 用时:31ms
  • 内存:11448kb
  • [2024-11-06 13:06:13]
  • 提交

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;
}

詳細信息

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