数论
Napoleon2004
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
UVA 11582 Colossal Fibonacci Numbers!
#include<bits/stdc++.h> using namespace std; int s[1000010]; int ksm(unsigned long long a,unsigned long long b,int m){ if(b==0)return 1; int x=ksm(a,b/2,m); x=(x*x)%m; if(b%2)x=(...原创 2018-04-01 19:50:26 · 130 阅读 · 0 评论 -
POJ 2478 Farey Sequence
#include<cstdio> const int m=1e6; int l,a[m+1]; bool b[m+1]; long long s[m+1]; void zs(){ long long i,j; b[1]=0; for(i=2;i<=m;i++) if(b[i]==0){ a[++l]=i; for(j=i*i;j<=m;j+=i) ...原创 2018-04-26 14:16:26 · 155 阅读 · 0 评论 -
POJ 1845 Sumdiv
#include<cstdio> using namespace std; typedef long long ll; const int M=9901; ll p[100],k[100]; ll power(ll n,ll m){ ll sq=1; while(m){ if(m&1)sq=sq*n%M; m>>=1; n=n*n%M; } re...原创 2018-05-18 09:27:04 · 236 阅读 · 0 评论 -
BZOJ 2301 [HAOI2011]Problem b
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=50000; int p[N+10],mbs[N+10]; bool vis[N+10]; void mobius(){ int i,j; mbs[1]=1; for(i=2;i<=N;i++){ ...原创 2018-05-06 11:54:16 · 211 阅读 · 0 评论 -
POJ 2992 Divisors
#include<cstdio> using namespace std; const int M=431; bool b[M+5]; int l,p[M+5],jie[M+5][M+5]; void jc(){ int i,j; for(i=2;i<=M;i++) if(b[i]==0){ for(j=i*i;j<=M;j+=i) b[j]=1; ...原创 2018-05-13 10:07:14 · 177 阅读 · 0 评论 -
HDU 2824 The Euler function
#include<bits/stdc++.h> using namespace std; const int MAXN=3000000; bool b[MAXN]; int p[MAXN],phi[MAXN]; void get_phi(){ phi[1]=1; int i,j,cnt=0; for(i=2;i<MAXN;i++){ if(...原创 2018-05-07 10:05:18 · 200 阅读 · 0 评论 -
POJ 2480 Longge's problem
#include<cstdio> using namespace std; typedef long long ll; ll p[6010],prime[50010]; ll l,d,ans,s[20],k[20],b[20]; void get_prime(){ ll i,j; prime[0]=prime[1]=1; for(i=2;i<=50000;i++) if...原创 2018-05-21 01:25:39 · 162 阅读 · 0 评论 -
HDU 1452 Happy 2004
#include<bits/stdc++.h> using namespace std; int qpow(int m,int n){ int k=m,s=1; while(n){ if(n&1)s=s*k%29; k=k*k%29; n>>=1; } return s; } int m...原创 2018-05-21 01:27:56 · 212 阅读 · 0 评论 -
HDU 1023 Train Problem II
#include<bits/stdc++.h> using namespace std; int k[110][1010]; void out(int n){ int i; for(i=k[n][0];i>=1;i--) printf("%d",k[n][i]); printf("\n"); } void cal(int x,int y,i...原创 2018-05-21 01:29:39 · 173 阅读 · 0 评论 -
POJ 3090 Visible Lattice Points
#include<cstdio> int s[1001]; int gcd(int x,int y){ if(x%y==0)return y; return gcd(y,x%y); } int pd(int i,int j){ if(i==0&&j==0||i==0&&j!=1||i!=1&&j==0)return 0; if(i...原创 2018-04-26 14:15:00 · 156 阅读 · 0 评论 -
POJ 2417 Discrete Logging
第一次写BSGS算法。#include<cstdio> #include<cmath> #include<map> using namespace std; map<long long,int>mp; long long a,b,c,m; long long qsm(long long x){ long long sum=1,aa=a; whil...原创 2018-04-04 10:21:09 · 164 阅读 · 0 评论 -
Codeforce 7C Line
A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from - 5·1018 to 5·1018 inclusive, or to find out that s...原创 2018-04-04 10:17:36 · 200 阅读 · 0 评论 -
UVA 12169 Disgruntled Judge - NWERC 2008 扩展欧几里得
#include<bits/stdc++.h> using namespace std; long long s[300]; long long exgcd(long long a,long long b,long long& x,long long& y){ if(!b){ x=1; y=0; return a; } long long d=...原创 2018-04-01 19:52:04 · 250 阅读 · 0 评论 -
UVA 10375 Choose and divide 唯一分解定理
#include<bits/stdc++.h> using namespace std; const int M=20010; int b[M],e[M]; vector<int>prime; void ss(int n){ int i,j; b[1]=1; for(i=2;i<=n;i++) if(b[i]==0)//==0就是素数 ==1就不是 ...原创 2018-04-01 19:53:34 · 212 阅读 · 0 评论 -
UVA 10791 Minimum Sum LCM 唯一分解定理
#include<bits/stdc++.h> using namespace std; int main(){ long long n,i,m,t,sum,ans,kase=0; while(scanf("%lld",&n)&&n){ kase++; ans=0; m=0; t=n; if(n==1){ printf("Case ...原创 2018-04-01 19:54:50 · 184 阅读 · 0 评论 -
UVA 12716 GCD XOR - ACM/ICPC Dhaka 2013
#include<bits/stdc++.h> using namespace std; int n,i,t,a,b,c,ans[30000010]; int main(){ n=30000000; for(c=1;c<=(n>>1);c++) for(a=2*c;a<=n;a+=c){ b=a-c; if(c==(a^b))ans[a]++...原创 2018-04-01 19:56:14 · 188 阅读 · 0 评论 -
UVA 1640 The Counting Problem - ACM/ICPC Shanghai 2004
#include<bits/stdc++.h> using namespace std; int a1[10],a2[10],b[10]; int qpow(int n){ if(n<0)return 0; int sum=1; while(n--)sum*=10; return sum; } void f1(int n){ int s=1,m=0; while(s*...原创 2018-04-03 09:45:39 · 259 阅读 · 0 评论 -
HDU 3037
Lucas 大组合求模#include<bits/stdc++.h> using namespace std; long long fac(long long n,long long p){ long long sum=1; for(long long i=1;i<=n;i++) sum=sum*i%p; return sum; } long long qpow(lon...原创 2018-03-28 10:40:32 · 170 阅读 · 0 评论 -
HDU 2669 Romantic
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll exgcd(ll x,ll y,ll& a,ll& b){ ll ret,tmp; if(y==0){ a=1; b=0; return x; } re...原创 2018-04-04 10:08:50 · 128 阅读 · 0 评论 -
NOIP 2012 D2T1 同余方程
#include<cstdio> using namespace std; int x,y; int gcd(int a,int b){ if(!b){ x=1; y=0; return a; } int r=gcd(b,a%b); int t=x; x=y; y=t-a/b*y; ...原创 2018-04-04 10:13:11 · 202 阅读 · 0 评论 -
[SDOI2008]仪仗队
题目描述 作为体育委员,C君负责这次运动会仪仗队的训练。仪仗队是由学生组成的N * N的方阵,为了保证队伍在行进中整齐划一,C君会跟在仪仗队的左后方,根据其视线所及的学生人数来判断队伍是否整齐(如下图)。 现在,C君希望你告诉他队伍整齐时能看到的学生人数。 输入输出格式 输入格式: 共一个数N 输出格式: 共一个数,即C君应看到的学生人数。 #incl...原创 2018-07-29 11:02:51 · 254 阅读 · 0 评论
分享