标签:模板
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <climits>
using namespace std;
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define LL long long
#define N 100005
const int mod=1e9+7;
const int INF=1<<30;
const double PI= acos(-1.0);
//----------------------结构体按num为第一要素t为第二要素name为第三要素排序------------------------------------
struct node
{
int num;
int t;
char name[20];
};
int cmp(const node a,const node b)
{
if(a.num==b.num&&a.t==b.t)//字符串从小到大排序
{
return strcmp(a.name,b.name)<0;
}
else if(a.num==b.num&&a.t!=b.t)
{
return a.t<b.t;//从小到大排序
}
else
{
return a.num>b.num;//从大到小排序
}
}
//-------------------------------------------
//-------------------求a和b的最大公约数------------------------
LL gcd(LL a,LL b)
{
return b>0?gcd(b,a%b):a;
}
//-------------------------------------------------------------
//-------------------------求a^b------------------------------
LL exp(LL a,LL b)
{
LL ans=1;
while(b--)
{
ans=ans*a;
}
return ans;
}
//---------------------------------------------------------------
//----------------快速判断一个数是不是素数,0和1不要输入---------------------------
int prime(int n)
{
if(n==2||n==3)
{
return 1;
}
if(n%6!=1&&n%6!=5)
return 0;
for(int i=5;i*i<=n;i+=6)
{
if(n%i==0||n%(i+2)==0)
return 0;
}
return 1;
}
//------------------------------------------------------------------------------
int main()
{
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:模板
原文地址:http://blog.csdn.net/xky1306102chenhong/article/details/47004559