ACM_关闭同步流 ios::sync_with_stdio(false);

  1. cin和cout比scanf和printf慢很多,因为先把要输出的东西存入缓冲区,再输出,导致效率降低。
  2. scanf和printf在cstdio中
  3. std::ios::sync_with_stdio(false);关闭输入输出缓存,可以加快cin和cout

还有就是,用\n而不是 endl,也可以提高速度。

猜你喜欢

转载自blog.csdn.net/aaakkk_1996/article/details/81192816