1 条题解

  • 0
    @ 2025-8-24 23:10:13

    自动搬运

    查看原文

    来自洛谷,原作者为

    avatar 喵仔牛奶
    黄昏再美终要黑夜。

    搬运于2025-08-24 23:10:13,当前版本为作者最后更新于2024-08-02 19:17:25,作者可能在搬运后再次修改,您可在原文处查看最新版

    自动搬运只会搬运当前题目点赞数最高的题解,您可前往洛谷题解查看更多

    以下是正文


    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;
    }
    
    • 1

    信息

    ID
    10612
    时间
    1000ms
    内存
    512MiB
    难度
    1
    标签
    递交数
    0
    已通过
    0
    上传者