結果

問題 No.171 スワップ文字列(Med)
ユーザー wing3196wing3196
提出日時 2015-03-23 00:24:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 954 bytes
コンパイル時間 653 ms
コンパイル使用メモリ 76,668 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 09:41:40
合計ジャッジ時間 1,473 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define int long long
#define MOD 573

int int_pow(int n,int m){
	ll ans = 1;
	while(m--){
		ans *= n; ans %= MOD;
	}
	return ans;
}

void latte(int A[1001],int n){
	for(int i=2;n!=1;i++){
		while(n%i==0){
			A[i]++;
			n /= i;
		}
	}
}

signed main(){
	string S;
	int cnt[26] = {}, A[1001] = {}, B[1001] = {};
	cin>>S;
	for(int i=0;i<S.size();i++) cnt[S[i]-'A']++;
	for(int i=S.size();i>1;i--) latte(A,i);
	for(int i=0;i<26;i++){
		for(int j=2;j<=cnt[i];j++){
			latte(B,j);
		}
	}
	ll ans = 1;
	for(int i=2;i<=S.size();i++){
		if(A[i]-B[i]==0) continue;
		ans *= int_pow(i,A[i]-B[i]); ans %= MOD;
	}
	printf("%d\n",(ans+MOD-1)%MOD);
	return 0;
}
0