結果

問題 No.966 引き算をして門松列(その1)
ユーザー tamarontamaron
提出日時 2020-01-13 21:18:06
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 978 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 11,536 KB
実行使用メモリ 15,416 KB
最終ジャッジ日時 2023-08-24 14:04:22
合計ジャッジ時間 1,542 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,032 KB
testcase_01 AC 78 ms
15,128 KB
testcase_02 AC 79 ms
15,140 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 108 ms
15,328 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:5: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:13: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:30: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

T=gets.to_i
T.times do |i|
    a,b,c=gets.split.map(&:to_i)
    if [a,b,c].max<=2 || (a==1 && a==b) || (b==1 && b==c) || (c==1 && c==a)
        puts -1
        next
    end
    a,c=c,a if c<a
    if a==b && b==c
        if a>=3
            puts 3
        else
            puts -1
        end
    elsif a<b && b==c
        if a+1==c
            puts 2
        else
            puts 1
        end
    elsif  a==b && b<c
        if a+1==c
            puts 2
        else
            puts 1
        end
    elsif a<b && b<c
        if a==1
            if b==2
                puts -1
            else 
                puts c-b+1
            end
        else
            puts [b-a+1,c-b+1].min
        end
    elsif b<a && a==c
        if b+1==a
            puts 2
        else
            puts 1
        end
    elsif b==a && a<c
        puts 1
    elsif b<a && a<c
        puts 0
    elsif a==c && a<b
        puts 1
    elsif a<c && c<b
        puts 0
    end
end  
            

0