/*
Author:597
Description:
This is a Header File for coding.
It has many function which can make us coding easily or running quickly.
*/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
//File IO
#define I_O(x) freopen(""#x".in","r",stdin);freopen(""#x".out","w",stdout)
//for Pascal黨&碼速
#define forp(i,a,b) for(i=a;i<=b;i++)
#define form(i,a,b) for(i=a;i>=b;i--)
#define until(x) while (!(x))
//for "memset"
#define INF 2139062143
#define NINF -2139062144
//for 讀入優化
#define IN(x,a,b) (a<=x && x<=b)
template <typename T>
inline void input(T& x)//專爲讀整數設計
{
char ch=getchar();
while (!(IN(ch,'0','9')||ch=='-'))
ch=getchar();
if (ch!='-')
{
x=0;
do
{
x=x*10+ch-48;
ch=getchar();
}
while (IN(ch,'0','9'));
}
else
{
ch=getchar();
x=0;
do
{
x=x*10+ch-48;
ch=getchar();
}
while (IN(ch,'0','9'));
x=-x;
}
}
inline int get_int()//專爲讀int設計
{
char ch=getchar();
int x=0;
while (!(IN(ch,'0','9')||ch=='-'))
ch=getchar();
if (ch!='-')
{
do
{
x=x*10+ch-48;
ch=getchar();
}
while (IN(ch,'0','9'));
}
else
{
ch=getchar();
do
{
x=x*10+ch-48;
ch=getchar();
}
while (IN(ch,'0','9'));
x=-x;
}
return x;
}
//for math
template <typename T>
inline T sqr(T x){return x*x;}
template <typename T>
inline T pow(T x,T y)
{
T tmp=x,ret=1;
while (y)
{
if (y&1)
ret*=tmp;
y>>=1;
tmp*=tmp;
}
return ret;
}
//for random(including <cstdlib> and <ctime>)
#define randomize srand(time(0))
#define random(l,r) (l+rand()%(r-l+1))
//for string
#include <string>
using namespace std;
inline void input(string& s)//讀字符串
{
char ch=getchar();
while (!IN(ch,33,126))
ch=getchar();
s="";
do
{
s+=ch;
ch=getchar();
}
while (IN(ch,33,126));
}
inline void input_line(string& s)
{
char ch=getchar();
while (!IN(ch,32,126))
ch=getchar();
s="";
do
{
s+=ch;
ch=getchar();
}
while (IN(ch,32,126));
}
inline void output(string& s)//寫字符串(沒幫你換行,若是要換行打上putchar('\n');)
{
int i;
for (i=0;s[i]!='\0';i++)
putchar(s[i]);
}
方便人類——信息學訓練專用庫
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.