Something about C++

线性筛素数

	for(ll i = 2; i <= n; ++i)
	{
		if(!Bol[i])
		{
			prim[++t] = i;
			Bol[i] = 1;
		}
		for(ll j = 1; prim[j] * i <= n && j <= t; ++j)
			Bol[i * prim[j]] = 1;
	}

快读

inline ll read()
{
	ll x = 0, r = 1; char c = getchar();
	while(c < '0' || c > '9'){if(c == '-')r = -1;c = getchar();}
	while('0' <= c && c <= '9')x = x * 10 + c - 48, c = getchar();
	return x * r;
}

快输

void write(ll k)
{if(k > 9)write(k / 10); putchar(k % 10 + '0');}

快速幂

int power(int a,int b)
{
	int Ans = 1;
	a = a % mod;
	while(b)
	{
		if(b & 1) Ans = (ll) Ans * a % mod;
		a = (ll)a * a % mod;
		b >>= 1;
	}
	return Ans;
}

随机(初始化)

#include<ctime>
srand(time(0));

对拍

#include<windows.h>
#include<cstdio>
#include<ctime>
void dp()
{
	while(1)
	{
		system("dat.exe");
		double st1=clock(); system("A.exe"); double ed1=clock();
		double st2=clock();	system("T1.exe");double ed2=clock();
		if(system("fc T1.txt 1.txt"))
		{
		    printf("WA");
		    return;
		}
		else printf("AC time1:%0.2lf ms time2:%0.2lf ms\n",ed1-st1, ed2 - st2); 
		if(ed1 - st1 >= 1000 || ed2 - st2 >= 1000)
		{printf("TLE\n"); return;}
	}
}

int main()
{
	dp();
}

q u e u e queue queue

主要是想记录一下大、小根堆的写法

#include<queue>

定义

priority_queue<int> p;//大根堆
priority_queue<int,deque<int>,greater<int> > q;//小根堆

结构体堆

struct wh
{
	int end, num;
	bool const operator <(const wh i)const
	{
		return i.end < end;
	}
};

m a p map map

本蒟蒻可能会有讲错的
望各位 d a l a o dalao dalao谅解

#include<map>

一般用法

实质跟数组差不多

定义

map<string,string>A;

第一个变量为下标变量
比如 i n t int int
那就是 A [ 1 ] A[1] A[1] A [ 2 ] A[2] A[2]
s t r i n g string string
那就是 A [ " M a p l e " ] A["Maple"] A["Maple"] A [ " M " ] A["M"] A["M"]

第一个变量为此数组的类型
比如 < i n t , i n t > <int,int> <int,int>
那就是 A [ 1 ] = 1 A[1]=1 A[1]=1 A [ 2 ] = 2 A[2]=2 A[2]=2
< s t r i n g , s t r i n g > <string,string> <string,string>
那就是 A [ " M a p l e " ] = " M a p l e " A["Maple"]="Maple" A["Maple"]="Maple" A [ " M " ] = " M " A["M"]="M" A["M"]="M"
当你放一个下标上去
如果它检测到没有过就开一个
且内容为空

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值