跳到正文

个人记录

rand.h更新啦

lihanyang约 1 分钟
原文
文章信息与版本

文章信息

发布
2018年12月5日
收录
2026年4月14日
更新
2026年11月16日
篇幅
约 1 分钟

版本

  1. v2当前
  2. v1
C++
#include<bits/stdc++.h>
namespace quick
{
	long long pow(int p,int k,int mod)//p的k次方%mod
	{
		long long ans=1,b=k,base=p;
		while(b > 0)
    	{
	        if(b & 1)
	        {
	            ans *= base;
	            ans %= mod;
	        }
	        base *= base;
	        base %= mod;
	        b >>= 1;
    	}
		return ans;
	}
}
int dfs_dir(int direction,int is_x)
{
	int dirx[9]={0,0,0,-1,1,-1,-1,1,1};
	int diry[9]={0,1,-1,0,0,1,-1,1,-1};
	if(is_x==0) return dirx[direction];
	if(is_x==1) return diry[direction];
	return 0;
}
原文