char In[1 << 20], *ss = In, *tt = In;
#define getchar() (ss == tt && (tt = (ss = In) + fread(In, 1, 1 << 20, stdin), tt == ss) ? EOF : *ss++)
整数:
读入:
int read (char ch = 0) {
register ll x = 0, f = 1;
while (ch < '0' || ch > '9') f = ch == '-' ? -1 : 1, ch = getchar();
while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
return x * f;
}
读出:
inline void write(ll x) {
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10ll);
putchar(x%10+48);
}
字符串:
读入:
char getch (char ch = 0) {
while (ch < 'A' || (ch > 'Z' && ch < 'a') || ch > 'z') ch = getchar();
return ch;
}
读出:
inline void putch(string s)
{
for(int i=0; s[i]!='\0'; i++) putchar(s[i]);
}
多次使用的变量如:
for(int i...)
写成
for(register int i...)
加完 register 以后 内存里会记录下这个变量以后调用不会一直声明.
inline :写函数之前如果这个函数会一直调用加上inline 内联函数声明
头文件部分:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#define endl '\n'
氧气优化部分。
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include<bits/stdc++.h>
#pragma optimize(2)
#define endl '\n'
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef unsigned long long ull;
const int M=2010;
const int P=13331;
const ll llinf=0x3f3f3f3f3f3f3f3f;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int N=2e6+10;
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};
void solve()
{
return ;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("test.in","r",stdin);
int t;cin>>t;
while(t--)solve();
return 0;
}
一般短小没循环的函数加内联可以,有for循环的编译器一般不通过内联的,我看你写的那个读出的例子给了inline,其实编译器还是会按照普通函数调用来处理的,你可以读读effective c++第一章吧应该是