結果

問題 No.443 GCD of Permutation
ユーザー azaa414
提出日時 2025-01-25 16:48:23
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,307 bytes
コンパイル時間 2,322 ms
コンパイル使用メモリ 114,012 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-25 16:48:27
合計ジャッジ時間 1,932 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:45:13: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   45 |     for (ri i = 0; i <= 9; ++i)
      |             ^
main.cpp:46:17: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   46 |         for (ri j = 0; j < i; ++j)
      |                 ^

ソースコード

diff #
プレゼンテーションモードにする

#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define ll long long
#define ri register int
#define rl register long long
#define mst(x,y) memset(x, y, sizeof(x))
#define ciallo putchar('\n')
#define ilv inline void
#define ili inline int
#define ilb inline bool
#define ill inline long long
constexpr auto N = 1000010;
ll gcd(ll a, ll b)
{
return b ? gcd(b, a % b) : a;
}
string str;
vector<ll> b;
bool check(ll x)
{
ll temp = 0;
for (auto i : str)
temp = (temp * 10 + i - '0') % x;
return temp;
}
bool vis[20];
int main()
{
/*freopen("gcd.in", "r", stdin);
freopen("gcd.out", "w", stdout);*/
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> str;
ll t = 0;
for (auto i : str)
vis[i - '0'] = 1;
for (ri i = 0; i <= 9; ++i)
for (ri j = 0; j < i; ++j)
if (vis[i] && vis[j])
t = gcd(t, 9ll * (i - j));
if (!t)
{
cout << str;
return 0;
}
for (int i = t; i >= 1; --i)
{
if (!(t % i) && !check(i))
{
cout << i;
return 0;
}
}
fclose(stdin);
fclose(stdout);
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0