上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 24 下一页
摘要: n是质数<=>n没有小于等于sqrt(n)的素因子 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int maxn=1e5+2; 5 ll n; 6 int ans[maxn]; 7 阅读全文
posted @ 2017-08-25 20:15 shulin15 阅读(256) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=6178 【题意】 给定一棵有n个结点的树,现在有k个猴子分布在k个结点上,我们可以删去树上的一些边,使得k个猴子每个猴子都至少和其他一个猴子相连 问树上最少保留多少条边 【思路】 每个猴子要至少和一个猴子相连,考虑 阅读全文
posted @ 2017-08-24 20:45 shulin15 阅读(199) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=5692 【思路】 每更新一个点,子树的所有结点都要更新,所以是区间更新 每查询一个点,子树的所有结点都要查询,所以是区间查询最值 线段树上结点的值是每个点到根这条链的权值和 【AC】 1 #pragma comme 阅读全文
posted @ 2017-08-24 11:02 shulin15 阅读(169) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3887 【题意】 给定一棵树,给定这棵树的根 对于每个结点,统计子树中编号比他小的结点个数 编号从小到大一次输出 【思路】 从小到大处理每个结点,即统计当前结点的结果后,把当前结点插入到树状数组中 【AC】 1 # 阅读全文
posted @ 2017-08-23 20:59 shulin15 阅读(184) 评论(0) 推荐(0) 编辑
摘要: http://acm.bnu.edu.cn/v3/problem_show.php?pid=52733 【题意】 给定一棵树,这棵树每个点都有一个点权,标号从0开始,0是根结点 修改操作: SEED 1 13 把结点1的点权乘上13 查询操作: RAND 1 查询结点1为根的子树所有结点权的总乘积, 阅读全文
posted @ 2017-08-23 20:18 shulin15 阅读(209) 评论(0) 推荐(0) 编辑
摘要: poj.org/problem?id=3321 【题意】 给一棵n个节点的树,每个节点开始有一个苹果,m次操作 1.将某个结点的苹果数异或 1 2.查询一棵子树内的苹果数 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #i 阅读全文
posted @ 2017-08-23 15:05 shulin15 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 5 const int maxn=50005; 6 struct Seg 7 { 8 int l,r,mi,ma; 9 }tree[maxn*4]; 10 int va 阅读全文
posted @ 2017-08-22 19:11 shulin15 阅读(133) 评论(0) 推荐(0) 编辑
摘要: acm.hdu.edu.cn/showproblem.php?pid=1698 【AC】 1 #include<cstdio> 2 const int maxn=100005; 3 #define lson (i<<1) 4 #define rson (i<<1|1) 5 struct Seg 6 阅读全文
posted @ 2017-08-22 18:58 shulin15 阅读(157) 评论(0) 推荐(0) 编辑
摘要: acm.bnu.edu.cn/v3/contest_show.php?cid=9208#problem/G 【题意】 给定一个无向图,要求把这个无向图的点划分到不同的集合里,使得每个集合的点之间两两没有边相连 求最少划分到多少个集合 【思路】 相当于给一个图染色,相邻点染不同色(在不同集合),最少用 阅读全文
posted @ 2017-08-22 11:46 shulin15 阅读(243) 评论(0) 推荐(0) 编辑
摘要: http://acm.bnu.edu.cn/v3/contest_show.php?cid=9208#problem/J 【AC】 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 ll N,K; 5 阅读全文
posted @ 2017-08-21 23:45 shulin15 阅读(318) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 24 下一页