a_bottle @ 2019-12-22 17:53:57
因为有负数所以这么写的,本地测过了但是洛谷没过
求问原因
int read()
{
int x=0,q=0;
char ch=getchar();
if(ch=='-')
{
q=1;
}
while(ch<'0'||ch>'9')ch=getchar();
while(ch>='0'&&ch<='9')
{
x=(x<<3)+(x<<1)+ch-'0';
ch=getchar();
}
if(q)return -x;
return x;
}
by Resonaa @ 2019-12-22 17:55:59
@a_bottle
带#include<stdio.h>
的scanf
比快读还快,要快读有何用?
by schtonn @ 2019-12-22 17:57:32
@kevinhou ???
by VinstaG173 @ 2019-12-22 17:58:10
@a_bottle 你不一定一读就读到-
啊,读了几个空格再给你-
不就炸了?
by schtonn @ 2019-12-22 17:58:12
@kevinhou scanf
比快读快???
by Resonaa @ 2019-12-22 17:58:23
@l_x_l 这题用cin
都能过。
by a_bottle @ 2019-12-22 17:59:06
@Vexalwig_Goodwcoffin 所以应该怎么写啊
我太蒟了
by VinstaG173 @ 2019-12-22 17:59:36
@kevinhou 人家想练快读不行么……
by VinstaG173 @ 2019-12-22 18:00:02
@a_bottle 判断放第一个while里面
by a_bottle @ 2019-12-22 18:00:33
@Vexalwig_Goodwcoffin 谢谢
by VinstaG173 @ 2019-12-22 18:00:58
说句闲话,快读这种东西配合fread要好得多(虽然已经足够踩scanf了