I/O读入和输出

一般跑百万级别的数据用

inline int read()
{
    int X=0,w=1; char ch=0;
    while(ch<'0' || ch>'9') {if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0' && ch<='9') X=(X<<3)+(X<<1)+ch-'0',ch=getchar();
    return X*w;
}
inline void write(int x)
{
    if(x==0){putchar('0'),putchar('\n');return;}
    if(x<0)putchar('-'),x = -x;
    char s[64],l = 0;
    while(x!=0)s[++l] = x%10+48,x /= 10;
    for(int i=l;i>=1;i--) putchar(s[i]);
    putchar('\n'); //这里输出换行了,可以改
}

发布了130 篇原创文章 · 获赞 5 · 访问量 5001

猜你喜欢

转载自blog.csdn.net/weixin_44224825/article/details/104139027