返回题解分享
讨论 / 题解分享/ 帖子详情

年号字串(结果填空) - 题解

模拟进位




#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

using ll = long long;

int main() {
	int v = 2019;
	string res = "A";
	for (int i = 1; i < v; ++i) {
		bool up = false;
		for (int j = res.size() - 1; j >= 0; --j) {
			up = 0;
			++res[j];
			if (res[j] > 'Z') {
				up = 1;
				res[j] = 'A';
			}
			if (!up)
				break;
		}
		if (up)
			res.push_back('A');
	}
	cout << res << '\n';
	return 0;
}
0 回复 0 转发 1 喜欢 5 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!