跳到正文

个人记录

U541587 题解

Rgb_V约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v1当前

由题意模拟即可。

需要注意输出格式,可以使用printf控制输出。

code:

C++
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int T;
int main() {
    scanf("%d",&T);
    for (int t=1;t<=T;++t){
        ll n,p,res=1;
        cin>>n>>p;
        if (n>=p) res = 0;
        else{
            for (int i=1;i<=n;++i){
                res=res*i%p;
            }
        }
        printf("case #%d : %lld\n",t,res%p);
    }
    return 0;
}
原文