算法基本的板子

这里是准备打算法题比赛时的板子。

不用万能头文件版

#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
using namespace std;
/***********************
常量区 
************************/
typedef long long int LL;
const int N=1e5+10; 
const double pi=acos(-1);
/***********************
函数区 
************************/
void scan(__int128 &x)//输入
{
    
    
    x = 0;
    int f = 1;
    char ch;
    if((ch = getchar()) == '-') f = -f;
    else x = x*10 + ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        x = x*10 + ch-'0';
    x *= f;
}
void _print(__int128 x)
{
    
    
    if(x > 9) _print(x/10);
    putchar(x%10 + '0');
}
void print(__int128 x)//输出
{
    
    
    if(x < 0)
    {
    
    
        x = -x;
        putchar('-');
    }
    _print(x);
}
LL gcd(LL a,LL b)
{
    
    
	return b?gcd(b,a%b):a;
}
LL quick_mi(LL a,LL b,LL p)
{
    
    
	LL sum=1;
	while(b)
	{
    
    
		if(b&1) sum=sum*a%p;
		a=a*a%p;
		b=b>>1;
	}
	return sum%p;
}
int main()
{
    
    
	
    return 0;
}

万能头版本

#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
/***********************
常量区 
************************/
typedef long long int LL;
const int N=1e5+10; 
const double pi=acos(-1);
/***********************
函数区 
************************/
void scan(__int128 &x)//输入
{
    
    
    x = 0;
    int f = 1;
    char ch;
    if((ch = getchar()) == '-') f = -f;
    else x = x*10 + ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        x = x*10 + ch-'0';
    x *= f;
}
void _print(__int128 x)
{
    
    
    if(x > 9) _print(x/10);
    putchar(x%10 + '0');
}
void print(__int128 x)//输出
{
    
    
    if(x < 0)
    {
    
    
        x = -x;
        putchar('-');
    }
    _print(x);
}
LL gcd(LL a,LL b)
{
    
    
	return b?gcd(b,a%b):a;
}
LL quick_mi(LL a,LL b,LL p)
{
    
    
	LL sum=1;
	while(b)
	{
    
    
		if(b&1) sum=sum*a%p;
		a=a*a%p;
		b=b>>1;
	}
	return sum%p;
}
int main()
{
    
    
    return 0;
}

常用的简单轻易版

#include<bits/stdc++.h>
#define YES puts("YES");
#define Yes puts("Yes");
#define yes puts("yes");
#define NO  puts("NO");
#define No  puts("No");
#define no  puts("no");
using namespace std;
typedef long long int LL;
typedef pair<int,int> PII;
const int N=1e5*2+10;
const int mod=1e9+7;
int n,m,t;
int a[N];
int main(void)
{
    
    
	return 0;
}

加速器

#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")

快读

typedef long long int LL;
typedef pair<int,int> PII;
LL read()
{
    
    
    LL x=0;char ch;bool f=true;
    for(ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')f^=true;
    for(;isdigit(ch);ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
    return f?x:-x;
}

刷算法题时常用的函数手册

刷算法题时常用的函数手册

刷算法题总结的一些结论公式

刷算法题总结的一些结论公式

ACM之对拍

ACM之对拍

__int128板子

template <typename T>
inline T read()
{
    
    
    T sum = 0, fl = 1;
    int ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-')
            fl = -1;
    for (; isdigit(ch); ch = getchar())
        sum = sum * 10 + ch - '0';
    return sum * fl;
}


读入:  __int128_t a, b, c;
a = read<__int128_t>(), b = read<__int128_t>(), c = read<__int128_t>();

猜你喜欢

转载自blog.csdn.net/bettle_king/article/details/117756231
今日推荐