結果
| 問題 | No.443 GCD of Permutation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 16:25:32 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 645 bytes |
| 記録 | |
| コンパイル時間 | 1,168 ms |
| コンパイル使用メモリ | 148,676 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-23 16:35:51 |
| 合計ジャッジ時間 | 2,196 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 26 WA * 2 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/allocator.h:46,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:45,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ios_base.h:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ios:46,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
from main.cpp:1:
In member function 'void std::__new_allocator<_Tp>::deallocate(_Tp*, size_type) [with _Tp = char]',
inlined from 'constexpr void std::allocator< <template-parameter-1-1> >::deallocate(_Tp*, std::size_t) [with _Tp = char]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/allocator.h:215:35,
inlined from 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::deallocate(allocator_type&, pointer, size_type) [with _Tp = char]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/alloc_traits.h:649:23,
inlined from 'constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_destroy(size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/basic_string.h:305:34,
inlined from 'constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_dispose() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
ソースコード
#include <iostream>
#include <numeric>
using namespace std;
bool appear[15];
bool factor(string s, int mod) {
int x = 0;
for(char c : s) {
x = x * 10 + (c - '0');
x %= mod;
}
return !x;
}
int main() {
string n;
cin >> n;
for(auto c : n) {
appear[c - '0'] = true;
}
int g = 0;
for(int i = 0; i <= 9; i++) {
for(int j = 0; j < i; j++) {
if(appear[i] and appear[j]) {
g = gcd(g, 9 * (i - j));
}
}
}
for(int i = g; i >= 1; i--) {
if(g % i == 0 and factor(n, i)) {
cout << i;
return 0;
}
}
}