QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#203300#6956. Many Topological ProblemsRoyo#AC ✓50ms3820kbC++20799b2023-10-06 16:40:222023-10-06 16:40:23

Judging History

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

  • [2023-10-06 16:40:23]
  • 评测
  • 测评结果:AC
  • 用时:50ms
  • 内存:3820kb
  • [2023-10-06 16:40:22]
  • 提交

answer

#include <bits/stdc++.h>
#include <cstdio>
#define int long long
#define PII pair<int, int>
#pragma GCC optimize("Ofast")
#define NO {puts("No") ; return ;}
#define YES {puts("Yes") ; return ;}
#define pb push_back
#define endl "\n"
#define fi first
#define se second
#define IOS std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
mt19937 rd(time(0));
const int N = 1e5 + 10, mod = 1e9 + 7;

void solve() {
	int n, k; cin >> n >> k;
	int ans = 1;
	for (int i = 1; i <= n; i++)
	{
		ans = ans * i % mod;
		ans %= mod;
	}
	for (int i = 2; i <= n; i++)
	{
		ans = ans * min(i - 1, k) % mod;
		ans %= mod;
	}
	cout << ans << endl;

} 

signed main() {
    IOS;
    int t; cin >> t;
    while (t -- ) 
    solve();
    
    return 0;
}

详细

Test #1:

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

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