各种C++ main()签名及其效率

Akh*_*dey -1 c++ performance program-entry-point signature

最近我在竞争性编程网站上看到了以下给出的代码,

   #include<bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define d double
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

signed main()
{ return 0; //Omitted the rest of the code
}
[Full Code][1]
Run Code Online (Sandbox Code Playgroud)

https://www.codechef.com/viewsolution/22121098

我想知道这个代码和常规C++代码int main()在CPU速度方面的效率和性能方面有什么区别,问题集通常很大.

Wil*_*ler 5

signed main()相当于int main()除非 - 就像在示例中一样 - 你有一个定义intlong long. main() 必须返回 anint但宏#define int long long意味着int main()在这种情况下使用语法将不会编译并出现错误说明::mainmust return int。因此,signed main()

  • 这样的宏导致程序具有未定义的行为,即所有赌注都关闭。 (8认同)

Lig*_*ica 5

signedsigned int这也是int.

所以signed main() int main().

作者要么显得聪明,要么想要聪明而失败.