题解:FAOI-R4 A. 问题跳转
Solution
观察发现,需要开头加 P 的题号都是以数字开头的。若以数字开头,在字符串最前面加上 P 即可。
Code
参考代码:
#include <bits/stdc++.h>
#define REP(i, l, r) for (int i = (l); i <= (r); ++ i)
#define DEP(i, r, l) for (int i = (r); i >= (l); -- i)
#define fi first
#define se second
#define pb emplace_back
#define mems(x, v) memset((x), (v), sizeof(x))
using namespace std;
namespace Milkcat {
typedef long long LL;
typedef pair<LL, LL> pii;
const int N = 1e6 + 5;
string s;
int main() {
cin >> s;
if (isdigit(s[0])) s = "P" + s;
cout << "https://www.luogu.com.cn/problem/" << s << '\n';
return 0;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int T = 1; cin >> T;
while (T --) Milkcat::main();
return 0;
}