很容易可以得到,答案应该是(x+m*10^k)%n
很显然,用O(n)一定会卡爆,所以用快速幂来算,或者找一下循环节也是可以的。

#include <bits/stdc++.h>
using namespace std;
int Fact(int x, int n, int mod) {
    int ans = 1;
    while(n) {
        if(n & 1) ans = ans * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ans;
}
int main(int argc, char const *argv[])
{
    int n, m, k, x;
    cin >> n >> m >> k >> x;
    cout << ((x%n) + ((m%n)*Fact(10, k, n))%n)%n;
    return 0;
}

相关文章:

  • 2021-11-08
  • 2021-11-27
  • 2021-12-26
  • 2021-07-29
  • 2022-12-23
  • 2021-10-17
  • 2021-05-27
猜你喜欢
  • 2022-01-14
  • 2021-11-16
  • 2021-07-04
  • 2021-11-08
  • 2021-12-19
相关资源
相似解决方案