摘要:1 #include<stdio.h> 2 int prime[10]; //十个就够了,因为m最多有不超过10个素因子 3 long long pow(long long x,int y)//求x^y幂,用大整数 4 { 5 long long res=1; 6 while(y--) 7 res*=x; 8 return res; 9 }10 int main()11 {12 int i,j,n,m,t,tol=0;13 scanf("%d%d",&n,&m);14 t=m;15 long long re...
阅读全文
摘要:1 #include<iostream> 2 #include<cstdlib> 3 #include<stdio.h> 4 #include<string.h> 5 #define MAX 10005 6 using namespace std; 7 int cnt[MAX],num[MAX],prime[MAX]; 8 long long p[MAX]; //必须用大整数 9 void Solve(int n)10 {11 int i,j,tol=0;12 for(i=2;i*i<=n;i++)//计算素因子个数 13 {14 if(n
阅读全文
摘要:1 #include<stdlib.h> 2 #include<stdio.h> 3 int year,month,day; 4 int m[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31, 5 0,31,29,31,30,31,30,31,31,30,31,30,31}; 6 int y[660]={0}; 7 bool isrun(int year) 8 { 9 if((year%4==0&&year%100!=0)||year%400==0)10 return 1;11 return...
阅读全文
摘要:1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 double ans; 6 int n; 7 while(~scanf("%d",&n)){ 8 if(n<10000){ 9 ans=0.0;10 for(int i=1;i<=n;i++)11 ans+=1.0*n/i;12 printf("%lld\n",(long long)(ans+0.5));13 }else...
阅读全文
摘要:1 #include<stdio.h> 2 int main() 3 { 4 int i,res,n; 5 while(~scanf("%d",&n)){ 6 res=0; 7 while(n--){ 8 scanf("%d",&i); 9 res^=i;10 }11 printf("%d\n",res);12 }13 return 0;14 } 我们先了解一下位异或的运算法则吧:1、a^b = b^a。2、(a^b)^c = a^(b^c)。3、a...
阅读全文
摘要:1 #include<stdio.h> 2 #include<memory.h> 3 #define N 1000010 4 #define MOD 110023 5 int ind,key[N],next[N],order[N];//key[i]保存第i个小球的编号, 6 //next[]保存当出现冲突时同一余数对应的多个编号的值 7 //order[i]保存余数为i时对应的球的序号,进而找到其编号 8 void add(int n) 9 {10 int remainder;11 ...
阅读全文
摘要:1 #include<stdio.h> 2 int m[1000010]; 3 int main() 4 { 5 int i,n,c,q,from,to,inc; 6 scanf("%d%d%d",&n,&c,&q); 7 for(i=0;i<c;i++){ 8 scanf("%d%d%d",&from,&to,&inc); 9 m[from]+=inc; //从from-n都加上inc 10 m[to+1]-=inc; //从to+1-n都减去inc 11 }12 for(i=0;i&l
阅读全文
摘要:1 #include<stdio.h> 2 int m,n,tree[1000010]; 3 void update(int index,int inc)//注意插线问点与插点问线的区别 4 { 5 while(index>0){ 6 tree[index]+=inc; 7 index-=index&(-index); 8 } 9 }10 int sum(int index)11 {12 int sum=0;13 while(index<=n){14 sum+=tree[index];15 in...
阅读全文
摘要:1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 int father[1005]; 5 int degree[1005]; 6 int find(int x) 7 { 8 if(x!=father[x]) 9 father[x]=find(father[x]);10 return father[x];11 }12 void merge(int x,int y)13 {14 x=find(x);15 y=find(y);16 if(x!=y)17 ...
阅读全文
摘要:#include<stdio.h>#include<math.h>#include<string.h>#include<stdlib.h>struct Point{ double x; double y;}point[10010];int i,n,m;int main(){ scanf("%d",&n); while(n--){ scanf("%d",&m); double tmp,area=0,x=0,y=0; for(i=0;i<m;i++) scanf("%lf%lf&
阅读全文