結果

問題 No.171 スワップ文字列(Med)
ユーザー koyoprokoyopro
提出日時 2015-10-18 01:20:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,051 bytes
コンパイル時間 1,384 ms
コンパイル使用メモリ 157,476 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-28 22:03:01
合計ジャッジ時間 2,113 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
int gcd(int a, int b) { if (!b) return a; return gcd(b, a%b); }
int pymod(int i, int j) {
    return (i % j + j) % j;
}

int N,T;
string S;
map<char, int> M;
int mod = 573;
signed main()
{
    cin >> S;
    REP(i,S.size()) M[S[i]]++;
    vector<int> mul;
    vector<int> div;
    int k = 0;
    for (auto&& kv : M) {
        REP(i,kv.second) {
            mul.push_back(++k);
            div.push_back(i+1);
        }
    }
    sort(ALL(mul), greater<int>());
    sort(ALL(div), greater<int>());
    for (auto&& d : div) {
        REP(i,mul.size()) {
            int g = gcd(mul[i], d);
            if (g > 1) {
                mul[i] /= d;
                d /= d;
            }
            if (d == 1) break;
        }
    }
    int ret = 1;
    for (auto&& m : mul) {
        ret *= m % mod;
        ret %= mod;
    }
    cout << pymod(ret - 1, mod) << endl;
    return 0;
}
0