結果
| 問題 |
No.2128 Round up!!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-11 17:09:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 325 ms / 2,000 ms |
| コード長 | 1,261 bytes |
| コンパイル時間 | 367 ms |
| コンパイル使用メモリ | 82,380 KB |
| 実行使用メモリ | 80,696 KB |
| 最終ジャッジ日時 | 2024-08-11 17:09:27 |
| 合計ジャッジ時間 | 4,503 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 |
ソースコード
# cook your dish here
from collections import defaultdict,deque
from bisect import bisect_left,bisect_right
from itertools import accumulate,permutations,groupby
import sys
from math import gcd,isqrt
import heapq
import math
import string
#from sortedcontainers import SortedSet, SortedList, SortedDict
#import pulp
import random
#from more_itertools import*
#from functools import cache
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
#sys.setrecursionlimit(10**6)
#input=lambda :sys.stdin.readline()[:-1]
class ready():
def getint(self):
return int(input())
def getflo(self):
return float(input())
def getmanyint(self):
return map(int,input().split())
def gettree(self,n):
g=[[] for _ in range(n)]
for _ in range(n-1):
u,v,c=map(int,input().split())
g[u-1].append([v-1,c])
g[v-1].append([u-1,c])
return g
R=ready()
#ここからコ―ド
t=R.getint()
mod=998244353
for _ in range(t):
x,a,b=R.getmanyint()
A,B=max(a,b),min(a,b)
nA=-(-x//A)*A
nB=-(-x//B)*B
lcm=math.lcm(A,B)
nAB=-(-x//lcm)*lcm
ans=1
if nA!=x and nB!=x:
ans+=1
if nA>nB:
ans+=1
ans+=(nAB-nA)//A*2
ans%=mod
print(ans)