Author: lllyouo
Date: 20250702
tag: 同余、快速幂
link: https://www.luogu.com.cn/problem/P2818问题描述
分析
计算
参考代码
cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, ans;
string s;
cin >> n >> s;
for (int i = 0; i < s.size(); i++) {
ans = (ans * 10 + s[i] - '0') % n;
}
if (ans == 0) {
cout << n << endl;
} else {
cout << ans << endl;
}
return 0;
}