上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 54 下一页
  2023年4月11日
摘要: 给定区间 [L,R](1≤R<(1<<30) R−L≤1e6 ),请计算区间中素数的个数。 筛出 sqrt(R) 的质数p, 遍历 L~R 的数,看能否被p 约分,也就是合数,打个标记 #include <iostream> #include <cstring> #include <cmath> # 阅读全文
posted @ 2023-04-11 12:13 towboat 阅读(58) 评论(0) 推荐(0)
  2023年4月10日
摘要: 给出 n, 写成 n= x^p 的形式,求p最大值 #include <iostream> #include <vector> #include <cmath> #include <algorithm> using namespace std ; #define int long long int 阅读全文
posted @ 2023-04-10 22:36 towboat 阅读(16) 评论(0) 推荐(0)
摘要: #include <iostream> #include <cstring> #include <cmath> #include <algorithm> using namespace std ; const int M =1e6+33; #define int long long int b[M] 阅读全文
posted @ 2023-04-10 20:52 towboat 阅读(7) 评论(0) 推荐(0)
摘要: #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] ; 阅读全文
posted @ 2023-04-10 20:29 towboat 阅读(17) 评论(0) 推荐(0)
摘要: 选择K个质数,使它们的和等于N。问有多少种方案? 例如,n=24, k=2时有3种方案:5+19=7+17=11+13=24 #include <iostream> #include <cstring> #include <cmath> #include <algorithm> using name 阅读全文
posted @ 2023-04-10 18:50 towboat 阅读(25) 评论(0) 推荐(0)
摘要: 对序列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 阅读全文
posted @ 2023-04-10 18:22 towboat 阅读(19) 评论(0) 推荐(0)
摘要: 类似 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) 阅读全文
posted @ 2023-04-10 16:57 towboat 阅读(15) 评论(0) 推荐(0)
摘要: #include<iostream> #include<algorithm> using namespace std; const int M=1e6; int vis[M+4],P[M+4],cnt; int fi[M+4]; void shai(int top){ cnt=0; fi[1]=1; 阅读全文
posted @ 2023-04-10 15:56 towboat 阅读(15) 评论(0) 推荐(0)
  2023年4月9日
摘要: 设计一个照明系统,一共有n(n<=1000)种灯泡可供选择,不同种类的灯泡必须用不同的电源,同一种灯泡则可以用一个,输入为一个n,以下n行,每行四个数值,代表电压V,电源费用K,每个灯泡费用C,所需灯泡数量L。n=0为结束标志。 为了省钱,你可以把一些灯泡换成电压更高的以节省电源的钱,但不能换成更低 阅读全文
posted @ 2023-04-09 22:30 towboat 阅读(15) 评论(0) 推荐(0)
摘要: 有两个盒子各有n (n<=2e5) 个糖,每天随机选一个(概率分别为p,1-p),然后吃一颗糖。直到有一天,没糖了!输入n,p,求此时另一个盒子里糖的个数的数学期望 假设最后某个盒子有 k 颗糖,然后计算概率即可 #include<iostream> #include<cstring> #inclu 阅读全文
posted @ 2023-04-09 17:35 towboat 阅读(17) 评论(0) 推荐(0)
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 54 下一页