結果

問題 No.3015 アンチローリングハッシュ
ユーザー koyumeishikoyumeishi
提出日時 2015-06-29 01:23:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 62,180 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 04:17:43
合計ジャッジ時間 2,584 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include "assert.h"
#include <fstream>
#include <vector>

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	a %= b;

	vector<int> v(b+1, -1);

	int i = 0;
	long long c = 1;

	while(true){

		if(v[c] < 0) v[c] = i;
		else break;

		c = (c*a)%b;
		i++;
	}

	int len = i+1;
	string s(len, 'a');
	string t(len, 'a');

	s[len-1-v[c]]	= 'b';
	s[len-1-i]	= 'c';

	t[len-1-i]	= 'b';
	t[len-1-v[c]]	= 'c';

	cout << s << endl;
	cout << t << endl;
	return 0;
}
0