結果

問題 No.1509 Swap!!
ユーザー marroncastle
提出日時 2021-05-14 23:34:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 82,768 KB
実行使用メモリ 78,088 KB
最終ジャッジ日時 2024-10-02 05:35:09
合計ジャッジ時間 5,060 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,os,io
input = sys.stdin.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
T = int(input())
ans = ['NO']*T
def extgcd(a, b): # ax + by = d
  if b==0:
    return a, 1, 0 # a・1 + b・0 = a (b = 0のとき)
  d, y, x = extgcd(b, a%b)
  y -= (a//b)*x
  return d, x, y
from math import gcd
for t in range(T):
  N, A, B = map(int, input().split())
  A, B = min(A,B), max(A,B)
  if A==1:
    ans[t] = 'YES'
  elif gcd(A,B)==1:
    if N >= A+B-1:
      ans[t] = 'YES'
print(*ans, sep='\n')
0