I learned this trick from hitonanode's submission on AtCoder.

The trick is like

struct fast_ios {
fast_ios(){
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
}
} fast_ios_;

What I used to do is like

#define FAST_READ ios::sync_with_stdio(false); cin.tie(nullptr);
int main() {
FAST_READ
cout << fixed << setprecision(10);
// ...
}

using this trick, the code becomes

struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } fast_ios_;
int main() {
// ...
}

I think macros are better avoided when alternatives are available.

Update 2020/5/21

There is another way to achieve the same function:

int fast_io = []() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
return 0;
}();

最新文章

  1. 【转】 iOS9.2-iOS9.3.3越狱插件清单
  2. CSS3媒体查询使用小结
  3. Windows下Nginx的安装与配置(转)
  4. nginx:配置详细说明
  5. editplus文本编辑器
  6. 《Apache服务用户身份验证管理》RHEL6.3
  7. 【Servlet】doGet()与doPost()的区别
  8. Linux read语法及浅析
  9. tar 基础
  10. Beijing Perl Workshop - Augest 10th, 2013
  11. 理解free命令
  12. [国嵌攻略][179][OpenSSL加密系统]
  13. Exchange Server 2010升级到Exchange Server 2016
  14. jsp面试题
  15. np.mgrid 用法
  16. 第四篇:记录相关操作 SQL逻辑查询语句执行顺序
  17. 20180323 DataTable增加DataRow方式优化
  18. IDEA 热部署- 自动编译设置
  19. 吴裕雄 数据挖掘与分析案例实战(10)——KNN模型的应用
  20. iOS UITextField的代理&lt;UITextFieldDelegate&gt;的几点笔记

热门文章

  1. DB 分库分表(4):多数据源的事务处理
  2. [心得]暑假Day 8
  3. IDEA:Process finished with exit code -1073741819 (0xC0000005)
  4. 【全网最优方法】JAVA初学:错误: 找不到或无法加载主类HelloWorld
  5. GLSL语法入门
  6. is幻梦 Linux命令之文件和目录操作命令(二)——查看文件内容cat、more、less、tail、head
  7. 【React自制全家桶】六、React性能优化(持续更新总结)
  8. UML学习笔记_02_UML初识(简单的流程)
  9. C++中 关于操作符的重载
  10. Maven 默认 SpringMVC-servlet.xml 基本配置