随笔 - 531
文章 - 0
评论 - 3
阅读 -
10215
随笔分类 - 数学
Neon Sign UVA - 1510
摘要:给定空间里的 n 个点,其中没有三点共线。每两个点之间都用红色或黑色的线段连接。 求 3 条边同色的三角形个数。 n≤1000n≤1000。 同色的= 总数- 杂色的 杂色的直接乘法原理就行,但注意ij 和ji 一样 #include <iostream> #include <cstring> #i
阅读全文
Exploring Pyramids UVA - 1362
摘要:给出一棵树的 dfs 序,求可能的构成方案数。 A______A_______ f[l ][ r] =sum{ f[l+1][k-1] *f[k][j] } #include <iostream> #include <cstring> #include <sstream> using namespa
阅读全文
UVA11806 Cheerleaders
摘要:你有一个n×m的网格图,现在你要将K个人放在网格中,满足一下条件: 网格图的四个边都至少有一个人。 每个格子上不能有两个人。 每个人必须都有位置。 注意:四个角的人可以同时算作在两个边上 容斥原理 J=0 时就是 allAnswer #include <iostream> #include <cst
阅读全文
Add Again UVA - 11076
摘要:define S ,it is sum of all possible permutationsof a given set of digits. For example, if the digits are <1 2 3>, then six possible permutations are<1
阅读全文
The Super Powers UVA - 11752
摘要:求1~2^64 区间里, 有多少合法数X 合法数: X= a^b ,至少存在2个不同的a #include <iostream> #include <algorithm> #include <vector> using namespace std; const int N =65536+3; int
阅读全文
Again Prime? No Time. UVA - 10780
摘要:给定 m,n ,求最大的 k 使得 m^k∣n! 分解质因数 #include <iostream> #include <cstring> #include <sstream> using namespace std; const int N =1e4+20; const int inf =1e9
阅读全文
UVA11889 Benefit
摘要:lcm(a,b)=c 给a,c ,求最小的b 质因数分解的好题 #include <iostream> #include <cstring> #include <sstream> using namespace std; #define int long long int a,b,c; int cn
阅读全文
一个研究课题 A Research Problem UVA10837
摘要:输入正整数m(m≤1e8),求最小的正整数n,使得φ(n)=m。n<=2e8。 #include<cstring> #include<algorithm> #include<iostream> #include <map> using namespace std; const int M=1e5+5
阅读全文
Semi-prime H-numbers UVA - 11105
摘要:所有形如4n+1(n为非负整数)的数叫H数。定义1是唯一的单位H数, H素数是指本身不是1,且不能写成两个不是1的H数的乘积。 H-半素数是指能写成两个H素数的乘积的H数(这两个数可以相同也可以不同)。 例如,25是H-半素数,但125不是。 输入一个H数h(h≤1000001),输出1~h之间有多
阅读全文
Computer Transformation UVA - 1647
摘要:初始串为一个1,每一步会将每个0改成10,每个1改成01,因此1会依次变成 01, 1001, 01101001,… 输入n(n≤1000),统计n步之后得到的串中, “00”这样的连续两个0出现了多少次 f =[0]*1003 g =[0]*1003 f[1]=0 g[1]=1 for i in
阅读全文
UVA1646 圈图的匹配 Edge Case
摘要:n个点连成一个圆,求没有公共点的边集的个数 不考虑第n条边 f[n] =f[n-1]+f[n-2] 现在考虑第n条边 ans=f[n]+f[n-2] f=[0]*10005 f[1]=1 f[2]=2 for i in range(3,10004): f[i] =f[i-1]+f[i-2] whil
阅读全文
Count UVA - 1645
摘要:f[n] = sum{ f[i] } ( (n-1)%i==0) f[1]=1 #include <iostream> #include <cstring> #include <cmath> #include <algorithm> using namespace std ; const int N
阅读全文
Divisors UVA - 294
摘要:求区间[L,R]的整数中哪一个的正约数最多。 一个数因数分解后, 它的约数Cnt = (a[j]+1) 的乘积 ,j是每个因数的个数 #include <iostream> #include <cstring> #include <cmath> #include <algorithm> using
阅读全文
P1835 素数密度
摘要:给定区间 [L,R](1≤R<(1<<30) R−L≤1e6 ),请计算区间中素数的个数。 筛出 sqrt(R) 的质数p, 遍历 L~R 的数,看能否被p 约分,也就是合数,打个标记 #include <iostream> #include <cstring> #include <cmath> #
阅读全文
Perfect P-th Powers UVA - 10622
摘要:给出 n, 写成 n= x^p 的形式,求p最大值 #include <iostream> #include <vector> #include <cmath> #include <algorithm> using namespace std ; #define int long long int
阅读全文
Almost Prime Numbers UVA - 10539
摘要:#include <iostream> #include <cstring> #include <cmath> #include <algorithm> using namespace std ; const int M =1e6+33; #define int long long int b[M]
阅读全文
Sum of Consecutive Prime Numbers UVA - 121
摘要:#include <iostream> #include <cstring> #include <cmath> #include <algorithm> using namespace std ; const int M =1e4+33; int b[M],c[M],tot; int s[M] ;
阅读全文
Sum of Different Primes UVA - 1213
摘要:选择K个质数,使它们的和等于N。问有多少种方案? 例如,n=24, k=2时有3种方案:5+19=7+17=11+13=24 #include <iostream> #include <cstring> #include <cmath> #include <algorithm> using name
阅读全文
Magical GCD UVA - 1642
摘要:对序列A, 求 (j-i+1) * gcd( i, i+1, ... j ) 最大值 G(i) =gcd( G[i-1] ,a[i] ) 即前缀值不升 维护 1~j-1 可能的 i 值 (logn 个) O(n *log^2 #include <iostream> #include <map> #i
阅读全文
uva10214 Trees in a Wood.
摘要:类似 https://www.cnblogs.com/towboa/p/17303216.html , 不过给的是n ,m (n<=2000) 枚举 i (1<=i<=n) ,考虑 有多少 j (1<=j<=m) gcd__(i,j)==0 然后分段考虑 (gcd(x,y) = gcd(x,y-x)
阅读全文