結果

問題 No.443 GCD of Permutation
ユーザー mamekinmamekin
提出日時 2016-11-12 14:09:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,028 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 100,340 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-17 02:50:36
合計ジャッジ時間 2,255 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int gcd(int a, int b){
    while(b != 0){
        int tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    if(s == string(n, s[0])){
        cout << s << endl;
        return 0;
    }

    int x = 8;
    int y = 5;
    int z = 0;
    for(int i=0; i<n; ++i){
        x = gcd(x, s[i] - '0');
        y = gcd(y, s[i] - '0');
        z += s[i] - '0';
    }

    int ans = x * y;
    if(z % 9 == 0)
        ans *= 9;
    else if(z % 3 == 0)
        ans *= 3;
    cout << ans << endl;

    return 0;
}
0