跳到正文

题解

题解:「FAOI-R4」问题跳转

tanruiqing约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
题目
P11784

版本

  1. v1当前

题目大意:

给你一个字符串 ss。都是以大写字母开头。如果是数字开头,说明这道题是主题库中的题。所以要加上一个字母 P。最后输出这个题目的链接。

思路:

我们可以用一个 check 函数来检查开头是不是大写字母。是的话就返回 0,否则返回 1。如果返回 0,就直接输出 https://www.luogu.com.cn/problem/<PID>,否则输出 https://www.luogu.com.cn/problem/P+<PID>。(PID 是什么?看题目去)。

AC 代码:

C++
#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;
}
原文