![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
-----------数论-----------------
ajsdfkjasdfasdif
这个作者很懒,什么都没留下…
展开
-
HDOJ 5752 double精度
#includeusing namespace std;int main(){ double n; while(scanf("%lf",&n)!=EOF) { int i; for(i=1;;i++) { n=floor(sqrt(n)); if(n==1) break;原创 2016-08-16 14:41:39 · 196 阅读 · 0 评论 -
HDOJ2028 递推 求最小公倍数
#include"iostream"using namespace std; int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }int main(){ int n; while(cin>>n) { int i; int a[100]; for(i=1;i<=n;i++) cin>>a[i]; int dp原创 2016-05-25 23:13:17 · 710 阅读 · 2 评论 -
HDOJ 1130 卡塔兰数
import java.util.Scanner;import java.math.BigDecimal;import java.math.BigInteger;public class Main{ public static void main(String [] args) //a[1]=1 a[n]=(4*n-2)*a[n-1]/(n+1); { Scanner cin原创 2016-05-25 22:56:31 · 261 阅读 · 0 评论 -
HDOJ3763 二分查找
#include"iostream"#include"map" //二分查找#include"vector"#include"set"#include"list"#include"algorithm"using namespace std;const int maxn=100000+10;int a[maxn];int n,m;int find(int t){ int原创 2016-05-24 15:37:00 · 341 阅读 · 0 评论 -
POJ1953菲波那切数列
#include"iostream"#include"cstdio"#include"string"#include"algorithm"using namespace std; //题目意思就是输入长度n的串只有0和1的组合,但是不能有相邻的1,我是看网上才知道是fibonacciint main(){ //freopen("a.txt","r",stdin); lon原创 2016-05-21 16:36:02 · 376 阅读 · 0 评论 -
HDOJ1097 幂取模
#include"iostream"#include"algorithm"#include"sstream"#include"cstdio"#include"cstring"#include"cctype" #include"functional"using namespace std;int pow_mod(int a,int n,int m){ if(n==0) retur原创 2016-05-17 20:27:30 · 233 阅读 · 0 评论 -
vjios 1042 打表
#include"stdio.h"typedef long long ll;int a[779]={5,7,11,101,131,151,181,191,313,353,373,383,727,757,787,797,919,929,10301,10501,10601,11311,11411,12421,12721,12821,13331,13831,13931,14341,14741,1原创 2016-08-22 21:06:51 · 397 阅读 · 0 评论 -
VJIOS 大素数 MR测素数法+DFS
#include"stdio.h"#include"stdlib.h"typedef long long ll;int a[4]={2,3,5,7}; //开头的数字一定是素数int b[4]={1,3,7,9};//后面的数字不可能是偶数和5ll mypow(ll a,ll b,ll m){ if(b==0) return 1; if(b==1)原创 2016-08-22 21:08:24 · 346 阅读 · 0 评论 -
VIJOS 1164 中国剩余定理 CRT
#include"stdio.h" //精度需要注意#include"iostream"using namespace std;typedef long long ll;int n,m[50],a[50];void E_gcd(ll a,ll b,ll &d,ll &x,ll &y){ if(!b) {d=a;x=1;y=0;} else{E_gcd(b,a%b,d,原创 2016-08-23 02:08:29 · 293 阅读 · 0 评论 -
VIJOS1200 高精度乘法 素数判定
#include"stdio.h"#include"iostream"#include"cstring"using namespace std;typedef long long ll;ll len;bool is_prime(ll x){ for(int i=2;i*i<=x;i++) if(x%i==0) return false; return原创 2016-08-23 03:15:49 · 578 阅读 · 0 评论 -
VIJOS 1279
#include"stdio.h"#define swap(a,b) long long t=a;a=b;b=ttypedef long long ll;int main(){ ll a,b; while(scanf("%I64d%I64d",&a,&b)!=EOF) { ll ans=0; for(;;) {原创 2016-08-23 03:49:54 · 310 阅读 · 0 评论 -
HDOJ2095 异或运算
0^n=n; //和任何数异或都为na^b=b^a=1(a!=b);//满足交换律 不同的数异或等于1a^a=0;//相同的数异或等于0#include"iostream"using namespace std;int main(){ int n; while(scanf("%d",&n)==1&&n) { int a; int result=0; for(int原创 2016-05-26 13:15:24 · 271 阅读 · 0 评论 -
HDOJ1060 数论
借鉴新浪博客bysen#include"algorithm"#include"iostream"#include"queue"#include"vector"#include"cstdio"#include"cstring"#include"string"#include"cmath"#include"sstream"#include"list"#include"set"原创 2016-06-23 17:40:05 · 338 阅读 · 0 评论 -
POJ 1845 唯一分解定理
#include using namespace std;typedef unsigned long long llong;const int mod=9901;int p[4000],len=0,top[32][2],tlen;bool s[7072]={true,true};void split(llong n){ tlen=0; int i; for(i原创 2016-08-29 14:58:08 · 349 阅读 · 0 评论 -
TJU 1038 素数表
1038. Prime LandTime Limit: 1.0 Seconds Memory Limit: 65536KTotal Runs: 785 Accepted Runs: 395 Multiple test filesEverybody in the Prime Land is using a prime base number sy原创 2016-08-19 00:52:21 · 249 阅读 · 0 评论 -
TJU 1100 Pi double精度 gcd
1100. PiTime Limit: 1.0 Seconds Memory Limit: 65536KTotal Runs: 6001 Accepted Runs: 2420Professor Robert A. J. Matthews of the Applied Mathematics and Computer Science Department原创 2016-08-19 01:40:53 · 422 阅读 · 0 评论 -
POJ 1401 JB蛋疼
#include typedef long long ll;int main(){ int n; int t; scanf("%d",&t); while(t--) { scanf("%d",&n); ll cnt=0; while(n/5) { cnt+=n/原创 2016-08-29 17:22:04 · 344 阅读 · 0 评论 -
poj 1036 n!/(n-m)!*m!
#include#include"cstdio"using namespace std;typedef long long ll;int main(){ int n,m; while(scanf("%d%d",&n,&m),(n+m)) //n!/(n-m)!m! = 1...m,m+1...n 消 1...m 剩下 m+1...n/1...n-m原创 2016-08-30 04:43:43 · 519 阅读 · 0 评论 -
poj 1565 题目说啥你就做啥!
#include#include"cstdio"#include"string.h"#include"cmath"using namespace std;typedef long long ll;int main(){ char a[1000]; ll ans=0; while(scanf("%s",a)!=EOF) { if(a[0]=原创 2016-08-30 04:53:54 · 479 阅读 · 0 评论 -
POJ 1061 扩展欧几里得
#include"stdio.h"#include"iostream"#include"math.h"#include"algorithm"using namespace std;typedef long long ll;void gcd(ll a,ll b,ll &d,ll &x,ll &y){ if(b==0){d=a;x=1;y=0;return;} ll原创 2016-08-30 18:29:32 · 242 阅读 · 0 评论 -
POJ 3233 矩阵运算,等比数列二分求和,矩阵
#include"iostream"#include"stdio.h"#include"string.h"using namespace std;struct Mat{ int res[45][45]; Mat(){memset(res,0,sizeof(res));}}I;int n,m,k;Mat mut(Mat a,Mat b) //矩阵乘法{ Mat原创 2016-08-31 00:26:51 · 364 阅读 · 0 评论 -
HDOJ 2098 素数表
#include"iostream"#include"stdio.h"#include"vector"#include"string.h"using namespace std;const int maxn=10010;int prime[maxn];int main(){ int i,j; memset(prime,0,sizeof(prime)); pr原创 2016-08-09 19:59:41 · 372 阅读 · 0 评论 -
HDOJ N! Again 2674 同余
用公式 (a*b)%n=(a%n)*(b%n)%n还有就是 2009 = 7 * 7 * 4141!=41*40*...*21*...*7*...1;也就是说41以上的阶乘对2009取余都是为01%2009(1*2)%2009=(1%2009)*(2%2009)%2009(1*2*3)%2009=(1%2009)*(2%2009)*(3%2009)%2009%2009ans原创 2016-08-02 23:46:01 · 202 阅读 · 0 评论 -
UVA 10375 唯一分解定理
Choose and divideTime Limit: 3000MS 64bit IO Format: %lld & %lluSubmit Status uDebugDescriptionProblem descriptions:System Crawler 2016-08-19原创 2016-08-24 02:25:00 · 304 阅读 · 0 评论