結果

問題 No.540 格子点と経路
ユーザー maspy
提出日時 2020-01-02 11:13:46
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-22 17:51:13
合計ジャッジ時間 1,605 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x,y = map(int,read().split())

ev_x = x%2 == 0
ev_y = y%2 == 0
if ev_x and ev_y:
    answer = (x+1) * (y+1) - max(x,y)
    if x == y:
        answer -= 1
elif ev_x and (not ev_y):
    answer = (x+1) * (y+1) - y
elif (not ev_x) and ev_y:
    answer = (x+1) * (y+1) - x
else:
    answer = (x+1) * (y+1) - min(x,y)

if x == 0:
    answer = 1
if y == 0:
    answer = 1
if x + y == 0:
    answer = 0

print(answer)
0