結果
| 問題 |
No.171 スワップ文字列(Med)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-07-26 15:49:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,881 bytes |
| コンパイル時間 | 475 ms |
| コンパイル使用メモリ | 55,648 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-08 14:07:18 |
| 合計ジャッジ時間 | 1,061 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 2 |
ソースコード
//
// main.cpp
// Q414
//
// Created by AkihiroKOBAYASHI on 7/23/15.
// Copyright (c) 2015 Akhr5884. All rights reserved.
//
#include <iostream>
#include <string>
int bunshi[1000] = {0};
int bunbo[1000] = {0};
int count = 0;
void factorial(int n, int flag) {
if(n > 1) {
if(flag == 1) { // bunshi
bunshi[count] = n;
count++;
factorial(n-1, 1);
}
else if(flag == 0) { // bunbo
bunbo[count] = n;
count++;
factorial(n-1, 0);
}
}
// if (n > 0) {
// return n * factorial(n - 1);
// } else {
// return 1;
// }
}
int judge() {
while(1) {
if(bunbo[count] == 0) {
break;
}
for(int i = 0; bunshi[i] != 0; i++) {
if(bunshi[i]%bunbo[count] == 0) {
bunshi[i] = bunshi[i]/bunbo[count];
break;
}
}
count++;
}
count = 0;
int aaa = 1;
for(int i = 0; bunshi[i] != 0; i++) {
if(bunshi[i] != 0) {
aaa*=bunshi[i];
aaa = aaa%573;
if(aaa%573==0) {
aaa = 573;
}
}
}
return aaa-1;
}
int main(int argc, const char * argv[]) {
std::string s;
int flag[1000] = {0};
int now;
bunbo[0] = 1;
std::cin >> s;
const char *chr = s.c_str();
for(int i = 0; i < s.length(); i++) {
flag[i] = 1;
}
for(int i = 0; i < s.length()-1; i++) {
now = 1;
for(int j = i; j < s.length()-1; j++) {
if(chr[i] == chr[j+1] && flag[j+1] == 1) {
flag[j+1] = 0;
now++;
}
}
factorial(now, 0);
}
count = 0;
factorial((int)s.length(), 1);
count = 0;
std::cout << judge() << "\n";
return 0;
}