結果

問題 No.443 GCD of Permutation
ユーザー 10_oh_fu10_oh_fu
提出日時 2016-11-12 00:00:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,545 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 85,592 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 20:26:01
合計ジャッジ時間 1,745 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;

#define mod 1000000007

int main()
{
    string n;
    cin >> n;
    int count[10] = {};
    int sum = 0;
    for(int i = 0; i < n.length(); i++){
        int tmp = n[i] - '0';
        count[tmp]++;
        sum += tmp;
    }
    int num = 0;
    for(int i = 0; i < 10; i++){
        if(count[i] > 0) num++;
    }
    if(num == 1){
        cout << n << endl;
        return 0;
    }
    int ans = 1;
    if(sum % 9 == 0) ans = ans * 9;
    else if(sum % 3 == 0) ans = ans * 3;
    bool isalleven = true;
    for(int i = 0; i < 5; i++){
        if(count[2 * i + 1] > 0) isalleven = false;
    }
    if(isalleven){
        if(count[2] == 0 && count[4] == 0 && count[6] == 0) ans = ans * 8;
        else if(count[2] == 0 && count[6] == 0) ans = ans * 4;
        else ans = ans * 2;
        if(sum % 6 == 0){
            if(ans % 3 != 0 && ans % 2 != 0) ans = ans * 6;
            else if(ans % 3 != 0) ans = ans * 3;
            else if(ans % 2 != 0) ans = ans * 2;
        }
    }
    bool isallfiveorzero = true;
    for(int i = 1; i < 10; i++){
        if(i == 5) continue;
        else if(count[i] > 0) isallfiveorzero = false;
    }
    if(isallfiveorzero) ans = ans * 5;
    cout << ans << endl;
    return 0;
}
0