给出两个数 \(N\) 和 \(M\) ,求出 \(\lfloor \frac{10^N}{M} \rfloor \mod M\) 的值。
\(1≤N≤10^{18},1\leq M \leq 10000\)
题目链接:https://atcoder.jp/contests/arc111/tasks/arc111_a
真没想到可以这样做啊!
问题在于 \(N\) 的数值太大,又没有办法取模,可以转化为取模 \(M^2\)。原因如下:
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 24 19:33:54 2021
@author: hp
"""
n,m=map(int,input().split())
print(pow(10,n,m*m)//m%m)
AtCoder Regular Contest 111 A - Simple Math 2【数学思维】
原文:https://www.cnblogs.com/1024-xzx/p/14322133.html