結果

問題 No.443 GCD of Permutation
ユーザー 10_oh_fu
提出日時 2016-11-12 00:11:10
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,351 bytes
コンパイル時間 690 ms
コンパイル使用メモリ 86,652 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-25 10:33:45
合計ジャッジ時間 1,455 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20 WA * 8
権限があれば一括ダウンロードができます

ソースコード

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;
    }
    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