题目大意:
给你一个字符串 。都是以大写字母开头。如果是数字开头,说明这道题是主题库中的题。所以要加上一个字母 P。最后输出这个题目的链接。
思路:
我们可以用一个 check 函数来检查开头是不是大写字母。是的话就返回 0,否则返回 1。如果返回 0,就直接输出 https://www.luogu.com.cn/problem/<PID>,否则输出 https://www.luogu.com.cn/problem/P+<PID>。(PID 是什么?看题目去)。
AC 代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
string s;
bool check(string s){
if(s[0] < '0' || s[0] > '9'){
return false;
}
return true;
}
signed main(){
int n;
cin >> n;
while(n--){
cin >> s;
if(check(s) == false){
cout << "https://www.luogu.com.cn/problem/" + s << '\n';
}else{
cout << "https://www.luogu.com.cn/problem/P" + s << '\n';
}
}
return 0;
}