std::cin.tie(nullptr)->sync_with_stdio(false);
这行代码的作用是将std::cin的关联流设置为nullptr,然后将同步设置为false。这意味着输入操作不再与输出操作同步,可以独立进行。这在某些情况下可能会提高程序的性能,加快cin/cout读写速度。注意使用这行代码的时,不要和printf和scanf混用。
在这行代码中,箭头操作符 ->
用于调用 sync_with_stdio
方法。std::cin.tie(nullptr)
返回一个指向 std::cin
的关联流的指针,然后使用箭头操作符来调用 sync_with_stdio
方法,将其设置为 false
。
int i{}//初始化数据为0.
{}此方法可以初始化为0。
template <class T> constexpr T inf=std::numeric_limits<T>::max()/2;
template表示模板
class和typename等效
constexpr 和 const区别,都声明常量表达式,但constexpr为编译时确定值,const为运算时确定值。
std::numeric_limits<T>::max()求出类型最大值