結果
| 問題 |
No.171 スワップ文字列(Med)
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-03-23 01:10:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 645 bytes |
| コンパイル時間 | 476 ms |
| コンパイル使用メモリ | 60,032 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-29 00:20:20 |
| 合計ジャッジ時間 | 1,020 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 4 WA * 5 RE * 1 |
ソースコード
#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;
}
hogeover30