HDU 4737 A Bit Fun】的更多相关文章

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4737 题目大意:给定一系列数,F(i,j)表示对从ai到aj连续求或运算,(i<=j)求F(i,j)<=m的总数. 解题思路:或运算只会让值变大或保持不变.不断通过右移j来更新F(i,j),当aj>=m时所有的i<=j F(i,j)都大于等于m,因此从j后面继续扫数组:当aj<m而F(i,j)>=m时通过右移i来使F(i,j)<m.扫完整个数组即可. #include…
题意:定义F(i,j)为数组a中从ai到aj的或运算,求使F(i,j)<m的对数. 思路:或运算具有单调性,也就是只增不减,如果某个时刻结果大于等于m了,那么再往后一定也大于等于m.所以可以用两个指针i,j来维护一段区间,同时开一个数组记录二进制每位上的1的个数(类似于前缀和),利用该数组可以得到区间或的值.一旦大于m则i前移. #include<iostream> #include<algorithm> #include<cstdio> #include<…
题目链接 直接暴力,或运算只会越来越大 #include <cstdio> #include <cstring> using namespace std; #define N 100005 int a[N]; int main() { int n,m,cas,i,j,num,v; scanf("%d",&cas); v=1; while(cas--) { scanf("%d%d",&n,&m); for(i=0;i&l…
A Bit Fun Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 423    Accepted Submission(s): 270 Problem Description There are n numbers in a array, as a0, a1 ... , an-1, and another number m. We de…
题意:定义f(i, j) = ai|ai+1|ai+2| ... | aj (| 指或运算),求有多少对f(i,j)<m.1 <= n <= 100000, 1 <= m <= 230 分析:直接暴力.先固定左端点i,枚举j,当f(i,j)>=m时剪枝就行了,理论上O(n^2)的复杂度是过不了的,但是数据水了,加了那个剪枝后速度奇快.... 网上有O(30*n)的算法,但是我看了好久都没能理解=_= AC代码: #include<stdio.h> ],b[]…
A Bit Fun Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description There are n numbers in a array, as a0, a1 ... , an-1, and another number m. We define a function f(i, j) = ai|ai+1|ai+2| ... | aj . Wher…
第三题:HDU 4730 We Love MOE Girls 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4730 水题~~~ #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cstdlib> #include <cmath> #include <vector&…
HDU 3555 Bomb dp[i][0] 表示含 i 位数的方案总和. sp[i][0] 表示对于位数为len 的 num 在区间[ 10^(i-1) , num/(10^(len-i)) ] 内的方案数. 对于dp[i][3],dp[ i ][ 0 ]表示位数为 i 且含49的方案数,dp[ i ][1]表示位数为 i 且不含49 且末尾不为4的方案数,dp[ i ][2]表示位数为 i 且不含49且末尾为4的方案数. 对于sp[ i ][3].意义同样,仅仅只是要推断i-1位时的上界出如…
Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7194    Accepted Submission(s): 3345 Problem Description 话说上回讲到海东集团面临内外交困,公司的元老也只剩下XHD夫妇二人了.显然,作为多年拼搏的商人,XHD不会坐以待毙的.  一天,当他正在苦思冥想解困良策的…
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; int jc[100003]; int p; int ipow(int x, int b) { ll t = 1, w = x;…