视频加载失败

题解:P1001 A+B Problem

题解:P1001 A+B Problem
563 字
3 分钟
题解:P1001 A+B Problem

核弹打蚊子题。

正解#

人口普查代码,直接公布如下了:

#include <iostream>
using namespace std;
int a, b;
int main() {
cin >> a >> b;
cout << a + b << endl;
return 0;
}

整活#

声明:本文灵感来源于此文:文章公众号链接和知乎

首先,我们要请出一个预编译指令:define

{% folding::blue 什么是预编译指令? %}

首先,我们需要知道编译的流程。第一步就是这个预编译,这些指令一般以 # 开头,比如常见的 #include 就是,它的处理方法就是递归把被 #include 的东西塞到文件上去。

而这个 define 的作用类似于查找并替换(全字匹配),会被替换掉,之后不影响编译。同时注释也会在这个流程中被隐去。

接着就是编译和汇编,分别是把你的代码转换为汇编代码,然后才是机器码。然后会进行一种叫“链接”的操作,此时才算完毕。 {% endfolding %}

比如说,想开 long long 了,你是不是写过:#define int long long?(srds,根据 宝硕大佬的文章和相关标准,这个操作并不好)

然后,我们就可以写出酱紫的代码:

如图所示
如图所示

啊 bushi,是这个:

#define So include
#define I iostream
#define Say using
#define A namespace
#define little std
#define prayer int
#define my int
#define dreams main
#define will cin
#define take And
#define me hope
#define there cout
#define where And
#define the hope
#define skys endl
#define are return
#define blue 0
#include <iostream>
// 注意到预编译指令的周围都有非空格符号,不满足“全字匹配”的定义,因此不得不放弃这么搞。
// 在小 L 本地上,中文似乎会 CE,因此选了一首英文歌
// So I
Say A little;
prayer And, hope;
my dreams() {
will >> take >> me;
there << where + the << skys;
are blue;
}

AC 记录~


当然,也可以是这个:

#include <iostream>
#define _ using
#define __ namespace
#define ___ std
#define ____ int
#define _____ a
#define ______ b
#define _______ main
#define ________ cin
#define _________ cout
#define __________ endl
#define ___________ return
#define ____________ 0
_ __ ___;
____ _____, ______;
____ _______() {
________ >> _____ >> ______;
_________ << _____ + ______ << __________;
___________ ____________;
}

AC 记录~

老师:你搁这儿发电报呢

同学:古诗文填空中,发现没有题干,炸了

理解万岁!

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或打赏支持!

打赏
题解:P1001 A+B Problem
https://www.leo2011.eu.org/posts/luogu-p1001/
作者
Block_Fish
发布于
2025-05-10
许可协议
SATA

评论区

Profile Image of the Author
Block_Fish
大胆假设,小心求证。——胡适
公告
网站全面重构,有问题欢迎联系积木鱼!
分类
标签
最新动态
站点统计
文章
56
分类
7
标签
17
总字数
84,805
运行时长
0 天
最后活动
0 天前
站点信息
构建平台
Netlify CI
博客版本
Firefly v6.16.8
文章许可
SATA
文章目录