Light OJ
Aoxuets
REM 是我的, 拔剑吧!
展开
-
Light OJ 1085 - All Possible Increasing Subsequences
题目link 给定一个序列, 求出上升子序列的总数。分析Dp[i] 表示序列 以 i 结尾的数目。 可知 Dp[i]=∑Dp[x]+1Dp[i] = \sum Dp[x] + 1 这是一个前缀和, 用树状数组维护。Code#include <bits/stdc++.h>using namespace std; typedef long long LL; const int maxn = 1e原创 2016-05-14 22:04:00 · 376 阅读 · 0 评论 -
Light OJ 1078
题意: 给你 N,K 输出 KKKK.....KK能整除 N, 输出 K 的个数, (最小) 基础数学, 取摸运算即可。 #include using namespace std; typedef long long LL; int main() { int t; scanf("%d",&t); for(int kase = 1; kase <= t;原创 2016-03-14 10:59:51 · 271 阅读 · 0 评论 -
Light OJ 1020
简单推理题; #include using namespace std; int main() { int T, n; string Name; cin >> T; for(int kase = 1; kase <= T; ++kase) { cin >> n >> Name; if(Name ==原创 2016-03-14 10:59:49 · 367 阅读 · 0 评论 -
Light OJ 1012
经典搜索水题...... #include using namespace std; const int maxn = 20 + 13; const int step[4][2] = {0,1,0,-1,1,0,-1,0}; bool Vis[maxn][maxn]; char Map[maxn][maxn]; int Num, N, M; void BFS(int x,原创 2016-03-14 10:59:45 · 361 阅读 · 0 评论 -
Light OJ 1011
题意: (好难看) 给你 N 个 男的, 女的, 男的选女票, 题目给出矩阵, Mp[i][j] 表示 第 i 个男的选 第 J 个女的优先值 选了 J 之后的就不能选 J 了; 求所有狗男女的最大优先值 思路: Dp + 状态 压缩 #include using namespace std; const int maxn = 1<<16; int Mp[20][20原创 2016-03-14 10:59:42 · 244 阅读 · 0 评论 -
Light OJ 1009
题意: 给你一个二分图, (可能不连通) 求可能多的子集元素个数; 思路: 直接DFS 给二分图染色就有了, 统计联通块中个数, 去最大值相加即可。 #include using namespace std; const int maxn = 20000 + 131; struct Node { int One, Zre; }N[maxn / 2]; vector E[原创 2016-03-14 10:59:40 · 303 阅读 · 0 评论 -
Light OJ 1007
求区间欧拉函数平方和。。。 最后因为longlong 范围爆了WA 了, 0.0 #include using namespace std; const int maxn = 5000000 + 131; typedef unsigned long long LL; bool Com[maxn]; LL Num[maxn], Prim[maxn / 3]; int Cnt;原创 2016-03-14 10:59:38 · 391 阅读 · 0 评论 -
Light Oj 1005
题意: 从 n*n 的棋盘中放置 K 个 行和列不冲突的棋子 思路: 组合数学, 先选 k 个 行, k 个列, 就是 C(n,k) ^ 2; 然后 K 个棋子不相同, K ! 全排列 #include using namespace std; typedef long long LL; LL Num[40][40]; void Init() { Num[0][0原创 2016-03-14 10:59:33 · 314 阅读 · 0 评论 -
Light Oj 1003
题意 : 给你m个二元关系, 问是否可以确定各个节点的先后关系; 思路: 拓扑排序, 判断是否有环; #include using namespace std; const int maxn = 1e4 + 131; struct Node{ int nxt, to; }edge[maxn]; int Head[maxn], tot; void AddEdge(i原创 2016-03-14 10:55:55 · 377 阅读 · 0 评论 -
Light OJ 1116
基础数学:.. #include using namespace std; typedef unsigned long long ULL; int main() { int t; scanf("%d",&t); for(int kase = 1; kase <= t; ++kase) { ULL W; sca原创 2016-03-14 10:59:54 · 422 阅读 · 0 评论 -
Light OJ 1148
题意: 给你N 个人, 每个人说出有多少人和他一队, 不包括他自己, 输出总人数最少值 思路: 排个序, 按照给的数目把人分为一组,就可以得出最少人数 #include using namespace std; const int maxn = 50 + 13; int Num[maxn]; int main() { int t, N; scanf("%d",原创 2016-03-14 10:59:56 · 324 阅读 · 0 评论 -
Light OJ 1266 - Points in Rectangle
题目Link 就是查询矩形内有多少个点。分析二维树状数组维护就好了,。Code#include <bits/stdc++.h>const int maxn = 1000 + 131; struct Point { int x, y; }; int Num[maxn][maxn]; bool Vis[maxn][maxn];int lowbit(int x) { return x&(-x);原创 2016-05-15 09:27:51 · 435 阅读 · 0 评论 -
Light OJ 1343 - Aladdin and the Black Stones
题目link 求偶数子序列 满足 的个数。分析首先, 我们先把每一对a[i] + a[j]存起来, 这样就可以把题目的偶数个条件无视了。 设 T[i,j] = a[i] + a[j]; 因为我们是要求序列个数, 所以对于 [i,j]区间, 我们 要找出 [i,j] 内有多少对满足 T[x,y] < T[i,j] 的。 把 (i,j)想成坐标系的点, 那么上面求的就是 平面矩形 {[i,i],原创 2016-05-15 11:51:41 · 455 阅读 · 0 评论 -
LightOJ 1372 (枚举 + 树状数组)
题目Link 输出序列中有多少个组合 {a1,a2,a3,a4,a5,a6a_1 , a_2, a_3, a_4, a_5, a_6}可以构成一个六边形。分析序列每个数都不相等。 所以可以设 a1<a2<a3<a4<a5<a6。a_1 < a_2 < a_3 < a_4 < a_5 < a_6。 把六边形分解为 4 个三角形, 又可以得出 a1+a2+a3+a4+a5>a6a_1 + a_2原创 2016-05-17 21:14:10 · 470 阅读 · 0 评论 -
Light OJ 1102
题意: 给你一个数 N , 求分成 K 个数 (可以为 0 ) 的种数; 思路: 类似 在K个抽屉放入 N 个苹果, 不为0, 就是 在 n-1 个空隙中选 m-1个; 为 0, 就可以先在 K 个抽屉一个苹果, 之后类似了; 故答案就是 C(N+K-1, K-1); 数据大, 还控制内存。。。 按位乘 + 逆元 #include usi原创 2016-03-14 11:00:12 · 338 阅读 · 0 评论 -
Light OJ 1095
题意: 给你 N 个数, 总共有 N! 种排列, 现在 要你统计前 M 个数 刚好 有K 个数 在原来的位置上 的排列个数 思路: 首先 M 中选 K C(m,k); 则 共 剩下 n - k 个数, 而 n-m 个数中可以允许有数在原来的位置; 故 枚举 n-m 中有多少个数 在原来的位置上, 剩下的 n - k - i 个数 就是一个错排列了 (错排原创 2016-03-14 11:00:07 · 343 阅读 · 0 评论 -
Light OJ 1058
题意: 简单的就组合数 C(m,n); 数据多,大, 要预处理; #include using namespace std; typedef long long LL; const int maxn = 1e6 + 2; const LL MOD = 1000003; LL Pow_Mod(LL a, LL n) { LL ret = 1; while(原创 2016-03-14 11:00:05 · 318 阅读 · 0 评论 -
Light OJ 1214
简单大数模拟题; #include using namespace std; typedef long long ll; string Num; vector Big; ll MOD(vector Big, ll m) { ll ret = 0; for(int i = 0; i < Big.size(); ++i) { ret原创 2016-03-14 11:00:01 · 295 阅读 · 0 评论 -
LIght OJ 1179
题意: 约瑟夫环问题, 给你N 个人, 没K个出队, 问最后剩下的人的编号。 思路: 直接模拟会T, 对于N个人 , 是一个约瑟夫环问题, 当第一个人出队后, (标号一定为 k % n -1) 剩下的 (N - 1) 个人 为 k%n, k%n+1, .....n, 0, 1, ...... k%n - 2; 重新编个号 :为 0 , 1, 2, .... n-1原创 2016-03-14 10:59:58 · 444 阅读 · 0 评论 -
Light OJ 1402 (Dp + 树状数组)
题目:[LINK](http://www.lightoj.com/volume_showproblem.php?problem=1402) 给你一些点(SRT, R); 按照SRT排序, 然后再坐标系中画出这些点, 连成一条线。 线会有峰点(peak),一个点是峰点, 相邻两个点的 R 值都比它小 或 大。 然后WARush 要丧病的忽略一些点,(忽略第X点后,第 X 后面的点会前移! ) 会形成原创 2016-05-20 15:48:17 · 423 阅读 · 0 评论