結果
| 問題 |
No.3179 3 time mod
|
| コンテスト | |
| ユーザー |
prin_kemkem
|
| 提出日時 | 2025-06-13 21:48:09 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 2,000 ms |
| コード長 | 1,222 bytes |
| コンパイル時間 | 429 ms |
| コンパイル使用メモリ | 82,656 KB |
| 実行使用メモリ | 57,772 KB |
| 最終ジャッジ日時 | 2025-06-14 01:40:48 |
| 合計ジャッジ時間 | 3,419 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 42 |
ソースコード
from collections import defaultdict, deque, Counter
# from functools import cache
# import copy
from itertools import combinations, permutations, product, accumulate, groupby, chain
# from more_itertools import distinct_permutations
from heapq import heapify, heappop, heappush, heappushpop
import math
import bisect
# from pprint import pprint
from random import randint, shuffle, randrange
# from sortedcontainers import SortedSet, SortedList, SortedDict
import sys
sys.setrecursionlimit(5000)
input = lambda: sys.stdin.readline().rstrip('\n')
inf = float('inf')
mod1 = 10**9+7
mod2 = 998244353
def ceil_div(x, y): return -(-x//y)
#################################################
xy = [None, None] # ax+by = gcd(a, b)
def extend_gcd(a, b, r=0):
if b == 0:
xy[r] = 1
xy[r^1] = 0
return a
d = extend_gcd(b, a%b, r^1)
xy[r^1] -= a//b*xy[r]
return d
def crt(MR): # (x ≡ r mod m)
nm = 1
x = 0
for m, r in MR:
extend_gcd(nm, m)
x += (r-x)*xy[0]%m*nm
nm *= m
return x
N = int(input())
P, Q, R = map(int, input().split())
A, B, C = map(int, input().split())
x = crt([(P, A), (Q, B), (R, C)])
m = math.lcm(P, Q, R)
print(N//m + (N%m >= x))
prin_kemkem