跳到正文

题解

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

用户 1469385约 1 分钟
原文
文章信息与版本

文章信息

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

版本

  1. v1当前

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

题目分析

本体答题思路就是输入一个题目,输出其洛谷网址

C++
string e;cin>>e;
cout<<"https://www.luogu.com.cn/problem/"<<e<<endl;

但要注意的是:洛谷主题库里的题(P开头)可以省略P

C++
if(e[0]>='0'&&e[0]<='9') cout<<"https://www.luogu.com.cn/problem/P"<<e<<endl;

AC代码

C++
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
  		string e;cin>>e;
		if(e[0]>='0'&&e[0]<='9') cout<<"https://www.luogu.com.cn/problem/P"<<e<<endl;
		else cout<<"https://www.luogu.com.cn/problem/"<<e<<endl;
	}
}
原文