矩阵快速幂
摘要:在斐波那契数列中,Fib0=0,Fib1=1,Fibn=Fibn−1+Fibn−2(n>1)Fib0=0,Fib1=1,Fibn=Fibn−1+Fibn−2(n>1)。 给定整数n,求Fibnmod10000Fibnmod10000。 输入格式 输入包含多组测试用例。 每个测试用例占一行,包含一个整
阅读全文
posted @
2019-10-06 15:50
键盘侠牧师
阅读(119)
推荐(0) 编辑
表达整数的奇怪方式(中国剩余定理)
摘要:题目链接:https://www.acwing.com/problem/content/206/ 给定2n个整数a1,a2,…,ana1,a2,…,an和m1,m2,…,mn,求一个最小的非负整数x,满足∀i∈[1,n],x≡mi(mod ai)∀i∈[1,n],x≡mi(mod ai)。 输入格式
阅读全文
posted @
2019-09-04 14:39
键盘侠牧师
阅读(260)
推荐(0) 编辑
E - GCD HDU - 2588
摘要:The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the largest divisor common to a and b,For example,(1,
阅读全文
posted @
2019-08-22 16:44
键盘侠牧师
阅读(105)
推荐(0) 编辑
F - Star SPOJ - STARSBC
摘要:Fernando won a compass for his birthday, and now his favorite hobby is drawing stars: first, he marks N points on a circumference, dividing it into N e
阅读全文
posted @
2019-08-22 15:34
键盘侠牧师
阅读(192)
推荐(0) 编辑
C - Calculation 2 HDU - 3501 (欧拉)
摘要:Given a positive integer N, your task is to calculate the sum of the positive integers less than N which are not coprime to N. A is said to be coprime
阅读全文
posted @
2019-08-22 14:28
键盘侠牧师
阅读(177)
推荐(0) 编辑
大数求余
摘要:#include <iostream> using namespace std; string s; int main() { cin>>s; int b; cin>>b; for(int i=0;i<s.length();i++) { s[i]=s[i]-'0'; } long long ans=0; for(int i=0;i<s.length();i++) { ans=(ans*10+s[i
阅读全文
posted @
2019-08-19 19:07
键盘侠牧师
阅读(96)
推荐(0) 编辑
数论学习 算法模板(质数,约数)
摘要:6.更相减损术 适合于较大的数求最大公约数 若a>b: gcd(a,b) = gcd(b,a-b) = gcd(a,a-b) gcd(2a,2b) = 2gcd(a,b) 7.欧几里得算法 int gcd(int a,int b){ if (a < b) swap(a, b); return b =
阅读全文
posted @
2019-08-19 19:02
键盘侠牧师
阅读(146)
推荐(0) 编辑
Acwing 197. 阶乘分解
摘要:给定整数 N ,试把阶乘 N! 分解质因数,按照算术基本定理的形式输出分解结果中的 pipi 和 cici 即可。 输入格式 一个整数N。 输出格式 N! 分解质因数后的结果,共若干行,每行一对pi,cipi,ci,表示含有pciipici项。按照pipi从小到大的顺序输出。 数据范围 1≤N≤10
阅读全文
posted @
2019-08-19 16:10
键盘侠牧师
阅读(157)
推荐(0) 编辑
ACwing 196. 质数距离
摘要:#include <bits/stdc++.h> using namespace std; const int N = 1000010, M = 5000010; int v[M]; long long prime[N],prim[N]; int cun=0; int inint(int n) { for(int i=2;i<=n;i++) { if(!v[i]) { v[i]=i; prim[c
阅读全文
posted @
2019-08-19 15:44
键盘侠牧师
阅读(141)
推荐(0) 编辑