欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

c/c++快速读入模板

程序员文章站 2022-06-21 19:30:04
最近牛客刷题没无论怎样改样例都没法过,百度一波都是用的c语言直接过的,后来发现cin读取数据太慢了,于是找了网上的模板1.去除锁 //快速读取数据 std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);2.快速读入板子#define re registerinline long long read(){ re long long x=0,f=1; re char ch=get...

最近牛客刷题没无论怎样改样例都没法过,百度一波都是用的c语言直接过的,后来发现cin读取数据太慢了,于是找了网上的模板
1.去除锁

     //快速读取数据
     std::ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);

2.快速读入板子

#define re register
inline long long  read()
{
    re long long  x=0,f=1;
    re char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*f;
}

最后过了那道题,显然第二种比第一中快
c/c++快速读入模板

本文地址:https://blog.csdn.net/qq_41404210/article/details/107137003