結果

問題 No.726 Tree Game
ユーザー hedwig100hedwig100
提出日時 2020-04-29 12:45:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 1,194 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 8,340 KB
最終ジャッジ日時 2023-08-18 18:46:49
合計ジャッジ時間 2,002 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,340 KB
testcase_01 AC 15 ms
8,212 KB
testcase_02 AC 15 ms
8,240 KB
testcase_03 AC 14 ms
8,240 KB
testcase_04 AC 15 ms
8,296 KB
testcase_05 AC 15 ms
8,212 KB
testcase_06 AC 14 ms
8,144 KB
testcase_07 AC 15 ms
8,136 KB
testcase_08 AC 15 ms
8,232 KB
testcase_09 AC 15 ms
8,212 KB
testcase_10 AC 15 ms
8,304 KB
testcase_11 AC 13 ms
7,828 KB
testcase_12 AC 15 ms
7,936 KB
testcase_13 AC 15 ms
8,200 KB
testcase_14 AC 16 ms
8,140 KB
testcase_15 AC 15 ms
8,216 KB
testcase_16 AC 17 ms
8,280 KB
testcase_17 AC 20 ms
8,188 KB
testcase_18 AC 15 ms
7,828 KB
testcase_19 AC 20 ms
8,172 KB
testcase_20 AC 20 ms
8,220 KB
testcase_21 AC 18 ms
8,176 KB
testcase_22 AC 23 ms
8,212 KB
testcase_23 AC 20 ms
8,216 KB
testcase_24 AC 16 ms
8,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 **9 + 7
INF = 10 ** 10

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,n):
        if i * i > n:
            break
        if n%i == 0:
            return  False
    return True

def main():
    y,x = map(int,input().split())
    if is_prime(x) and is_prime(y):
        print('Second')
        return
    if is_prime(x):
        if x == 2:
            print('Second')
            return
        x += 1
        h,w = 1,0
        while not is_prime(y):
            h += 1
            y += 1
        while not is_prime(x):
            w += 1
            x += 1

    elif is_prime(y):
        if y == 2:
            print('Second')
            return
        y += 1
        h,w = 0,1
        while not is_prime(y):
            h += 1
            y += 1
        while not is_prime(x):
            w += 1
            x += 1
    else:
        x += 1
        y += 1
        h,w = 0,0
        while not is_prime(y):
            h += 1
            y += 1
        while not is_prime(x):
            w += 1
            x += 1
            
    if (h + w)%2 == 0:
        print('Second')
    else:
        print('First')              
if __name__ == '__main__':
    main()
0