基本算法 st
摘要:今天困得不行,就看了个小算法st,其实和线段树的作用一样, 不过这个算法没有用到数据结构,使用二进制优化的 是O(log(n)n)的时间预处理,然后以O(1)的时间返回(l,r)上的最大或最小 st的题目: P2880 [USACO07JAN]平衡的阵容Balanced Lineup 题解 P225
阅读全文
posted @
2019-08-29 11:12
键盘侠牧师
阅读(176)
推荐(0) 编辑
小A的数学题
摘要:小A最近开始研究数论题了,这一次他随手写出来一个式子, 但是他发现他并不太会计算这个式子,你可以告诉他这个结果吗,答案可能会比较大,请模上1000000007。 输入描述: 输出描述: 示例1 输入 复制 2 2 输出 复制 7 示例1 输入 复制 2 2 输出 复制 7 输入 复制 2 2 输入
阅读全文
posted @
2019-08-24 13:37
键盘侠牧师
阅读(210)
推荐(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) 编辑
Ping-Pong (Easy Version)的解析
摘要:原题链接:http://codeforces.com/problemset/problem/320/B 之前自己做的时候一直读不懂题意,看了大佬的博客才知道是用dfs写,一道暴力搜索大水题https://www.cnblogs.com/windysai/p/3531473.html 题目意思:有两种
阅读全文
posted @
2019-08-22 11:23
键盘侠牧师
阅读(451)
推荐(0) 编辑
余数之和BZOJ1257
摘要:给出正整数n和k,计算j(n, k)=k mod 1 + k mod 2 + k mod 3 + … + k mod n的值。 例如j(5, 3)=3 mod 1 + 3 mod 2 + 3 mod 3 + 3 mod 4 + 3 mod 5=0+1+0+3+3=7。 输入格式 输入仅一行,包含两个
阅读全文
posted @
2019-08-21 00:23
键盘侠牧师
阅读(113)
推荐(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) 编辑