竞赛之路-省时小技巧-万能头文件#include <bits/stdc++.h>

前几天参加了我人生中的第一个编程比赛——智算之道,在醒悟了自己特菜的同时,我发现大部分参赛选手没有用我常用的那些头文件,而是直接使用了一个神秘的头文件:#include <bits/stdc++.h>

在经过了面向百度和CSDN学习后我明白了这个头文件的用法,这是一个万能头文件,它包含了我们常用的#include 、#include 、#include 等头文件,大部分OJ都支持这个头文件,这会为我们在竞赛中节省掉选择头文件的时间而可以关注与解决问题本身上面。

但是在我将这个万能头文件写到VS2019中时却发现VS找不到这个头文件,于是我在CSDN上找到了解决方法,首先打开安装VS的目录:
找到 2019\Community\VC\Tools\MSVC\14.25.28610\include
路径
再新建文件夹命名为bits,打开文件夹,新建.txt文本文档命名为stdc++.h
再右键编辑,将下列代码粘贴进去,ctrl+s保存即可。

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

注:在竞赛之中为了节约时间我们选择这样做,但这样会造成编译浪费,所以在平时的编写代码时我们还是应该尽量少的使用不必要的头文件。

猜你喜欢

转载自blog.csdn.net/DGany/article/details/107516956