用scanf或快读
by WanderingTrader @ 2020-10-20 20:06:35
好像不用万能头要快一点
by qzhwmjb @ 2020-10-20 20:07:49
@[空木秋人](/user/345837) 把`endl`换成`\n`能快很多(尤其数据量大的时候)
by xyf007 @ 2020-10-20 20:16:56
@[zycany](/user/270791) scanf总是会比cin快吗?
by 空木秋人 @ 2020-10-20 20:40:32
@[xyf007](/user/68273) 惊!还有这种说法吗
by 空木秋人 @ 2020-10-20 20:41:11
@[空木秋人](/user/345837) `endl`的说明
`template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits> &std::endl(std::basic_ostream<_CharT, _Traits> &__os)`
Write a newline and flush the stream. This manipulator is often mistakenly used when a simple newline is desired, leading to poor buffering performance. See https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering for more on this subject.
by xyf007 @ 2020-10-20 20:58:08
@[空木秋人](/user/345837) **leading to poor buffering performance**
by xyf007 @ 2020-10-20 20:58:55
@[空木秋人](/user/345837)
1. 在数据量大的时候,scanf相比cin会有显著的效率提升,具体可见[lxl的这篇文章](/blog/user3296/oi-zhong-jian-dan-di-chang-shuo-you-hua),不过这题输入量小,可能影响不大
2. ```cout<<endl```相当于```cout<<"\n"<<flush```,其中`flush`会消耗一定时间
by WanderingTrader @ 2020-10-20 21:07:00
我
$$scanf$$
直接3ms
by liuzimingc @ 2020-12-24 20:58:36