結果

問題 No.171 スワップ文字列(Med)
ユーザー 4885rhkA4885rhkA
提出日時 2015-07-26 15:49:51
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,881 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 53,764 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 23:29:51
合計ジャッジ時間 1,265 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 3 ms
4,384 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 #

//
//  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;
}
0