結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,036 KB
testcase_01 AC 81 ms
15,140 KB
testcase_02 AC 83 ms
15,048 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 111 ms
15,436 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:5: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:11: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:34: 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<=2
            puts -1
        elsif 3<=a
            puts 3
        end
    elsif a==b && b<c
        puts 1
    elsif a<b && b==c
        puts 1
    elsif a==c && c<b
        if a+1==b
            puts 2
        else
            puts 1
        end
    elsif b<a && a==c
        if b+1==a
            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
    else
        puts 0
    end
end
            

0