結果

問題 No.443 GCD of Permutation
ユーザー Yut176
提出日時 2016-11-12 01:49:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,142 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 75,552 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-25 10:48:51
合計ジャッジ時間 1,330 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 19 WA * 9
権限があれば一括ダウンロードができます

ソースコード

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]-'0';
  bool f = true;
  bool f2 = true;
  bool f3 = true;
  vector<int> cnt(10, 0);
  vector<int> cnt2(10, 0);
  for(int i=0; i<n.size(); i++){
    tmp += n[i]-'0';
    if( a != n[i]-'0' ) f = false;

    if( (n[i]-'0')%2 != 0 ) f2 = false;
    if( (n[i]-'0')%4 != 0 ) f3 = false;

    if( (n[i]-'0') != 0 ) cnt[ n[i]-'0' ] = 1;
    cnt2[ n[i]-'0' ]++;
  }

  if( f ){
    cout << n << endl;
    return 0;
  }
  int ans = 1;

  // if( accumulate( cnt.begin(), cnt.end(), 0 ) == 1 ){
  //   for(int i=0; i<10; i++) if( cnt[i] != 0 && (i != 2 && i != 3 && i != 4 && i != 6 && i != 9 ) ) ans *= i;
  // }

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

  if( accumulate( cnt.begin(), cnt.end(), 0 ) == 1 && cnt[5] == 1 ){
    ans *= 5;
  }

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

  cout << ans << endl;

  return 0;
}




// EOF
0