Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
127482 黄一航 魔法生物 C++ 通过 100 0 MS 244 KB 371 2024-01-25 09:14:35

Tests(1/1):


#include <bits/stdc++.h> #define int long long using namespace std; int ksm(int a,int b,int p) { int res = 1,t = a; while (b) { if (b & 1) res = (res * t) % p; t = (t * t) % p; b >>= 1; } return res; } signed main() { int n; while (true) { cin >> n; if (!n) break; printf("%lld\n",(ksm(2,n - 1,n) + 1) % n); } return 0; }


测评信息: