跳到正文

个人记录

最短A+B AC代码

hexinzhe约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年5月10日
篇幅
约 2 分钟

版本

  1. v1当前

如标题所示

这个蒟蒻又开始整活了(我为什么说“又”)

今天,我们要讨论的是:

最短のA+B problemAC代码(对于P1000)\LARGE{\texttt{\color{red}{最短}}\texttt{の}^{\text{A+B problem}}}{\color{white}\colorbox{limegreen}{AC}}\texttt{代码}\small{(\texttt{对于P1000})}

首先是最标准的 C++ 代码:

C++
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	cout<<a+b;
}

长度:99

通过修改头文件,可以得到:

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

长度:94

接着,去除亿不必要的空白符号

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

长度:80

然后,把 using namespace std; 去掉,再把 cin 与 cout 之前加上std::

C++
#include<iostream>
int a,b;int main(){std::cin>>a>>b;std::cout<<a+b;}

长度:70

去掉 int main 中的 int :

C++
#include<iostream>
int a,b;main(){std::cin>>a>>b;std::cout<<a+b;}

长度:66

本蒟蒻第一次发博客,若要提意见,评论区排队,蟹蟹您的支持

原文