Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
127422 廖悦扬 魔法生物 C++ 通过 100 0 MS 244 KB 343 2024-01-25 09:03:19

Tests(1/1):


#include <bits/stdc++.h> using namespace std; int p; int fp(int n, int x) { if (x==0) return 1; if (x%2==0) { long long tmp =fp(n, x/2); return tmp * tmp % p; } return fp(n, x-1)*n % p; } signed main() { while (cin >> p && p != 0) { cout << (fp(2, p-1)+1+p)%p << '\n'; } return 0; }


测评信息: