結果

問題 No.396 クラス替え
ユーザー hirakich1048576
提出日時 2016-07-15 22:59:04
言語 Ruby
(3.4.1)
結果
AC  
実行時間 92 ms / 1,000 ms
コード長 304 bytes
コンパイル時間 53 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-11-17 11:06:20
合計ジャッジ時間 2,698 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:5: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
Syntax OK

ソースコード

diff #

$n, $m = gets.chomp.split(' ').map{|i| i.to_i(10)}
$x, $y = gets.chomp.split(' ').map{|i| i.to_i(10)}

def find_class (x, m, n)
x -= 1
d = (x / m) & 1
if d == 0 then
(x % m) + 1
else
m - (x % m)
end
end

a = find_class($x, $m, $n)
b = find_class($y, $m, $n)

if a == b then
puts "YES"
else
puts "NO"
end
0