csp考前必背
快读快写
LLL quick_read()
{
LLL x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
x=x*10+(ch-'0');
ch=getchar();
}
return x*f;
}
void quick_write(LLL x)
{
if(x<0)
{
putchar('-');
x=-x;
}
if(x>=10) quick_write(x/10);
putchar((x%10)+'0');
}
对拍
扩展名:.bat
:loop
gen.exe//随机生成数据
live_bf.exe//暴力程序
live_corr.exe//正解
fc live.out live.ans
if not errorlevel 1 goto loop
发现报错.dll的话试试在 dev 的编译选项加入 -static。
扩展名:.cpp
#include<bits/stdc++.h>
using namespace std;
int main()
{
while(1)
{
system("suiji.exe");
system("4838.exe");
system("w.exe");
if(system("fc 4838.out w.out")) break;
}
return 0;
}
随机生成数据
srand(time(0))
rand()
头文件:
#include<stdlib.h>
#include<time.h>
完整代码:
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<time.h>
using namespace std;
int main()
{
srand(time(0));
int n=100;
freopen("live.in","w",stdout);
int w=rand()%101;
cout<<n<<' '<<w<<endl;
for(int i=1;i<=n;i++)
{
int a=rand()%601;
cout<<a<<' ';
}
}
cin,cout关闭同步流
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
dev-c++ 开c++14和O2优化
工具-编译选项-编译时加入以下命令√
-std=c++14 -O2

浙公网安备 33010602011771号