結果

問題 No.501 穴と文字列
ユーザー umaumax
提出日時 2017-05-08 06:27:27
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 1,591 ms
コンパイル使用メモリ 58,564 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-14 16:38:50
合計ジャッジ時間 1,559 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>

using namespace std;

int main(int argc, const char* argv[])
{
	int N, D;
	cin >> N >> D;
	char A[] = {'A', 'B', 'C'};
	string s;
	int nB   = max(D - N, 0);
	int nA   = max(min(N - nB, D - nB), 0);
	int nC   = N - nB - nA;
	int nS[] = {nA, nB, nC};
	for (int j = 0; j < 3; j++)
		for (int i = 0; i < nS[j]; i++) s += A[j];
	cout << s << endl;
	return 0;
}
0