我只知道一用读入优化就RE,可是读入优化错在哪里呢?
by controlf3 @ 2019-02-06 17:22:08
@[controlf3](/space/show?uid=29097)
读入优化不是这么写的。
by agicy @ 2019-02-06 17:34:15
@[卢安来](/space/show?uid=38502) 没毛病呀
by t162 @ 2019-02-06 17:37:14
@[controlf3](/space/show?uid=29097)
读入优化不是这么写的。
正确的免费送你了。
```cpp
int read()
{
int x=0;
char ch=' ';
bool flag=false;
while(!isdigit(ch))
{
if(ch=='-')flag=true;
ch=getchar();
}
while(isdigit(ch))
{
x=(x<<3)+(x<<1)+(ch^'0');
ch=getchar();
}
return flag?-x:x;
}
```
by Smile_Cindy @ 2019-02-06 17:59:44
感觉你们的读入优化有点长。。。
来个简版:
```cpp
int read(){//快读(有符号版)
char c = getchar();int ret = 0;bool flag = 0;
while (c > '9' || c < '0'){
c = getchar();
if (c == '-') flag = 1;
}
while (c <= '9' && c >= '0') ret*=10 , ret += (c - '0') , c = getchar();
return (ret * (flag == 1 ? -1 : 1));
}
```
```cpp
int read(){//快读(无符号版)
char c = getchar();int ret = 0;
while (c > '9' || c < '0') c = getchar();
while (c <= '9' && c >= '0') ret*=10,ret += (c - '0'),c = getchar();
return ret;
}
```
by blank_stn @ 2019-02-06 18:53:26
@[controlf3](/space/show?uid=29097)
您可能错在少了这一句话:
```cpp
while (c > '9' || c < '0') c = getchar();
```
by blank_stn @ 2019-02-06 19:24:54
就读这么几个数打什么快读。。还不如cin吧
by yurzhang @ 2019-02-07 13:11:14
@[yurzhang](/space/show?uid=126486) 谢谢dalao,就是少了这一句。
好像是数据里第数字前还有其他的东西,我的读入优化读不进数,然后某个数除以了0,让后RE了
by controlf3 @ 2019-02-08 11:04:24
@[yurzhang](/space/show?uid=126486) 不好意思,@错人了
@[findabetterself](/space/show?uid=107812) 谢谢大佬
by controlf3 @ 2019-02-08 11:05:47