绝世好题bzoj4300】的更多相关文章

Description 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0(2<=i<=len). Input 输入文件共2行. 第一行包括一个整数n. 第二行包括n个整数,第i个整数表示ai. Output 输出文件共一行. 包括一个整数,表示子序列bi的最长长度. Sample Input 3 1 2 3 Sample Output 2 HINT n<=100000,ai<=2*10^9 递推 f[x]表示相应二进制位为1时的最优解 每一…
绝世好题 bzoj-4300 题目大意:题目链接. 注释:略. 想法: 二进制拆分然后用一个数组单独存一下当前答案即可. Code: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define N 100010 using namespace std; int a[N],p[32],f[N],mx[32]; inline char nc() {st…
[BZOJ4300]绝世好题(动态规划) 题面 BZOJ Description 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0(2<=i<=len). Input 输入文件共2行. 第一行包括一个整数n. 第二行包括n个整数,第i个整数表示ai. Output 输出文件共一行. 包括一个整数,表示子序列bi的最长长度. Sample Input 3 1 2 3 Sample Output 2 HINT \(n<=100000,ai<=2…
bzoj4300绝世好题 题意: 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0.n≤100000,ai≤10^9. 题解: 用f[i]表示当前二进制i为1的最长子序列长度.每次求所有((1<<i)&bi)==1的f[i]最大值max,将所有((1<<i)&bi)==1的f[i]变为max+1. 代码: #include <cstdio> #include <cstring> #include &l…
http://www.lydsy.com/JudgeOnline/problem.php?id=4300 f[i] 表示第i位&为1的最长长度 #include<cstdio> #include<iostream> #include<algorithm> using namespace std; void read(int &x) { x=; char c=getchar(); while(!isdigit(c)) c=getchar(); +c-';…
4300: 绝世好题 Time Limit: 1 Sec  Memory Limit: 128 MB Description 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0(2<=i<=len).   Input 输入文件共2行. 第一行包括一个整数n. 第二行包括n个整数,第i个整数表示ai.   Output 输出文件共一行. 包括一个整数,表示子序列bi的最长长度.   Sample Input 3 1 2 3 Sample Output 2…
4300: 绝世好题 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4300 Description 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0(2<=i<=len). Input 输入文件共2行. 第一行包括一个整数n. 第二行包括n个整数,第i个整数表示ai. Output 输出文件共一行. 包括一个整数,表示子序列bi的最长长度. Sample Input 3 1 2 3 Sam…
4300: 绝世好题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 564  Solved: 289[Submit][Status][Discuss] Description 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0(2<=i<=len). Input 输入文件共2行. 第一行包括一个整数n. 第二行包括n个整数,第i个整数表示ai. Output 输出文件共一行. 包括一个整数,表示子序列bi的…
4300: 绝世好题 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/problem.php?id=4300 Description 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0(2<=i<=len). Under two situations the player could score one point. ⋅1. If you touc…
HYSBZ(BZOJ) 4300 绝世好题(位运算,递推) Description 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0(2<=i<=len). Input 输入文件共2行. 第一行包括一个整数n. 第二行包括n个整数,第i个整数表示ai. Output 输出文件共一行. 包括一个整数,表示子序列bi的最长长度. Sample Input 3 1 2 3 Sample Output 2 Http HYSBZ:http://www.lydsy…