ACM中的ios::sync_with_stdio(false)与scanf,cin

版权声明:转载请注明出处:https://blog.csdn.net/qq1013459920 https://blog.csdn.net/qq1013459920/article/details/83548976

ACM比赛中cin,的使用比较耗时,因为默认的时候,cin与stdin总是保持同步的,也就是说这两种方法可以混用,而不必担心文件指针混乱,
所以一般会用ios::sync_with_stdio(false)来取消cin与stdin的同步,从而使cin达到和scanf相差无几的输入效率。

但是,有时候不注意,往往容易把ios::sync_with_stdio和scanf,printf混用,其实这样是有风险的(可能会WA),比如hdu1258Sum It Up这道题,单独的scanf和printf,或者cin,cout都能AC,可是混用就会WA

所以,

要不就全部scanf,printf,

要不就ios::sync_with_stdio(false)+全部cin,cout,

不要混用避免不必要的WA.

猜你喜欢

转载自blog.csdn.net/qq1013459920/article/details/83548976