求问快读快写
  • 板块学术版
  • 楼主XiaoYiii
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/10/21 20:14
  • 上次更新2024/10/21 21:26:19
查看原帖
求问快读快写
1025891
XiaoYiii楼主2024/10/21 20:14

以下这份模版可以正常在 luoguIDE 与 luogu 提交,但是 Dev_C++ 就会爆。

编译均为 C++14,开启 O2 优化,本地我栈开到了 256MB(1073741824)

#include<bits/stdc++.h>
#define ll long long
#define ls x << 1
#define rs (x << 1) | 1
using namespace std;

inline char gc()
{
    static char BB[1000000], * S = BB, * T = BB;
    return (S == T) && (T = (S = BB) + fread(BB, 1, 1000000, stdin), S == T) ? EOF : *S++;
}

template <typename T>
T read(){
    T x = 0, f = 1;
    char ch = gc();
    while(ch < '0' || ch > '9'){if (ch == '-') f = -1; ch = gc();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = gc();}
    return x * f;
}

template <> double read<double> (){
    double x = 0;
    int f = 1;
    char ch = gc();
    while(ch < '0' || ch > '9'){if (ch == '-') f = -1; ch = gc();}
    while(ch >= '0' && ch <= '9'){x = x * double(10) + double(ch - '0'); ch = gc();}
    if(ch == '.'){
        ch = gc();
        double now = 1;
        while(ch >= '0' && ch <= '9'){
            now /= double(10);
            x = x + now * double(ch - '0');
            ch = gc();
        }
    }
    return x * f;
}

template <typename T>
void read(T & t){
    T x = 0, f = 1;
    char ch = gc();
    while(ch < '0' || ch > '9'){if (ch == '-') f = -1; ch = gc();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = gc();}
    t = x * f;
}

template <> void read<double> (double & t){
    double x = 0;
    int f = 1;
    char ch = gc();
    while(ch < '0' || ch > '9'){if (ch == '-') f = -1; ch = gc();}
    while(ch >= '0' && ch <= '9'){x = x * double(10) + double(ch - '0'); ch = gc();}
    if(ch == '.'){
        ch = gc();
        double now = 1;
        while(ch >= '0' && ch <= '9'){
            now /= double(10);
            x = x + now * double(ch - '0');
            ch = gc();
        }
    }
    t = x * f;
}

template <typename T, typename...Args>
void read(T & value, Args & ... args){
    read(value);
    read(args...);
}


template <typename T>
void sprint(T x, int w = 0){
    if(x < 0){putchar('-'); x = -x;}
    char ch[20];
    int t = 0;
    while(x){
        ch[++t] = x % 10 + '0';
        x /= 10;
    }
    for(int i = t; i >= 1; i--){
        putchar(ch[i]);
    }
    if(t == 0) putchar('0');
    switch(w){
        case 1:{
            putchar(' ');
            break;
        }
        case 2:{
            putchar('\n');
            break;
        }
        default:{
            break;
        }
    }
}

template<typename T>
void mprint(const T & value){
    T x = value;
    sprint(x, 2);
}

template<typename T, typename ...Args>
void mprint(const T & value, const Args & ... args){
    T x = value;
    sprint(x, 1);
    mprint(args...);
}
int a, b;
int main(){
	read(a, b);
	mprint(a + b);
	return 0;
}
2024/10/21 20:14
加载中...