2 条题解
-
0
暴力
from math import sqrt,ceil,gcd,log;re=lambda:map(int,input().strip().split()) a, b, c = re() isFind = False for i in range(10, 101): if i % 3 == a and i % 5 == b and i % 7 == c: print(i) isFind = True if not isFind: print("No answer")
Chinese Remainder Theorem
对于此题,最小解为 (a_1 M_1 t_1 + a_2 M_2 t_ 2 + a_3 M_3 t_3) (mod M)
M = 105
M_1 = 105 / 3 = 35
M_2 = 105 / 5 = 21
M_3 = 105 / 7 = 15
M_i * t_i = 1 (mod m_i) (就是在求逆元,t_i 是 M_i 在模 m_i 意义下的逆元)
可以试出t_1 = 2, t_2 = 1, t_3 = 1,则最小解 x_0 就是 (70a + 21b + 15c) % 105
from math import sqrt,ceil,gcd,log;re=lambda:map(int,input().strip().split()) a, b, c = re() res = (70 * a + 21 * b + 15 * c) % 105 print(res if 10 <= res <= 100 else "No answer")
- 1
信息
- ID
- 132
- 时间
- 3000ms
- 内存
- 128MiB
- 难度
- 5
- 标签
- (无)
- 递交数
- 1171
- 已通过
- 430
- 上传者