結果

問題 No.443 GCD of Permutation
ユーザー Yut176Yut176
提出日時 2016-11-11 23:59:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 732 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 72,588 KB
実行使用メモリ 5,328 KB
最終ジャッジ日時 2023-08-16 20:25:47
合計ジャッジ時間 1,782 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;

int main(){

  string n;
  cin >> n;

  int tmp = 0;
  int a = n[0];
  bool f = true;
  bool f2 = true;
  bool f3 = true;
  for(int i=0; i<n.size(); i++){
    tmp += n[i]-'0';
    if( a != n[i] ) f = false;
    if( n[i]%2 != 0 ) f2 = false;
    if( n[i]%4 != 0 ) f3 = false;
  }
  if( f ){
    cout << n << endl;
    return 0;
  }

  int ans = 1;
  if( tmp % 3 == 0 ) ans = 3;
  if( tmp % 9 == 0 ) ans = 9;

  if( f3 ){
    ans *= 4;
  }else if( f2 ){
    ans *= 2;
  }

  cout << ans << endl;

  return 0;
}




// EOF
0