結果

問題 No.358 も~っと!門松列
ユーザー satanicsatanic
提出日時 2016-04-17 22:41:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 833 bytes
コンパイル時間 535 ms
コンパイル使用メモリ 57,052 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 02:21:01
合計ジャッジ時間 1,070 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>

int max3(int a, int b, int c){
    return std::max(a, std::max(b, c));
}
int min3(int a, int b, int c){
    return std::min(a, std::min(b, c));
}
int diff3(int a, int b, int c){
    return (a!=b && b!=c && c!=a);
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    int a1, a2, a3, ans=0;
    std::cin >> a1 >> a2 >> a3;
    int maxNum = max3(a1, a2, a3);
    if(!diff3(a1, a2, a3)){
        std::cout << "0\n";
    }else if(a2==max3(a1, a2, a3) || a2==min3(a1, a2, a3)){
        std::cout << "INF\n";
    }else{
        for(int p=1; p<=maxNum; ++p){
            if(diff3(a1%p, a2%p, a3%p) && (a2%p==max3(a1%p, a2%p, a3%p) || a2%p==min3(a1%p, a2%p, a3%p))){
                ++ans;
            }
        }
        std::cout << ans << "\n";
    }

    return 0;
}
0