B3812 [语言月赛 202307] std::string 题解

· · 题解

B3812 [语言月赛 202307] std::string 题解

problem 1

很显然的,用 ans + ans = base 来存储 HelloLuogu 在 n 的范围极大时会超时(直接炸掉),所以我们的 hack 数据显然是 100000(10^5)。如果输入 100000,那么程序至少要跑 10 秒。

problem 2

我们可以发现,第二个循环的循环范围是 2 \sim n,所以只要程序输入一个 0,那么就会 WA 掉。

code

#include <bits/stdc++.h>

using namespace std;

const int kMaxN = -1;

string s[3] = {"", "100000", "5\n0\n114\n0\n114\n514"};

int main() {
    int id;
    cin >> id;
    cout << s[id];
    return 0;
}