結果

問題 No.171 スワップ文字列(Med)
ユーザー hogeover30hogeover30
提出日時 2015-03-23 01:10:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 645 bytes
コンパイル時間 435 ms
コンパイル使用メモリ 60,736 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 09:42:02
合計ジャッジ時間 1,139 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 RE -
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
const int mod=573;
int extgcd(int a, int b, int& x, int& y)
{
    int d=a;
    if (b) {
        d=extgcd(b, a%b, y, x);
        y-=a/b*x;
    }
    else {
        x=1;
        y=0;
    }
    return d;
}
int inv(int a)
{
    int x, y;
    extgcd(a, mod, x, y);
    return (mod+x%mod)%mod;
}
int main()
{
    string s;
    cin>>s;
    int a[256]={}, f[600]={};
    f[0]=1;
    for(int i=1;i<600;++i) f[i]=f[i-1]*i%mod;
    for(char c: s) a[c]++;
    int res=f[s.size()];
    for(int v: a) if (v) res=res*inv(f[v])%mod;
    res=(res-1+mod)%mod;
    cout<<res<<endl;
}
0