QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#318164#6956. Many Topological Problemsluyiming123AC ✓50ms3924kbC++23370b2024-01-30 16:47:552024-01-30 16:47:55

Judging History

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

  • [2024-01-30 16:47:55]
  • 评测
  • 测评结果:AC
  • 用时:50ms
  • 内存:3924kb
  • [2024-01-30 16:47:55]
  • 提交

answer

# include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7; 
int main(void)
{
    int Test; scanf("%d", &Test);
    while(Test--)
    {
        int n, k; scanf("%d%d", &n, &k); 
        int prod = 1; 
        for(int i = 2; i <= n; i++) prod = 1ll * prod * min(i - 1, k) % mod * i % mod; 
        printf("%d\n", prod); 

    }
    return 0; 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 50ms
memory: 3924kb

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