A Bit Fun

Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1148    Accepted Submission(s): 644

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 . Where "|" is the bit-OR operation. (i <= j)
The problem is really simple: please count the number of different pairs of (i, j) where f(i, j) < m.
 
Input
The first line has a number T (T <= 50) , indicating the number of test cases.
For each test case, first line contains two numbers n and m.(1 <= n <= 100000, 1 <= m <= 230) Then n numbers come in the second line which is the array a, where 1 <= ai <= 230.
 
Output
For every case, you should output "Case #t: " at first, without quotes. The t is the case number starting from 1.
Then follows the answer.
 
Sample Input
2
3 6
1 3 5
2 4
5 4
 
Sample Output
Case #1: 4
Case #2: 0
 
Source


关键是理解位或运算
#include<stdio.h>
int a[];
int main()
{
int t,cou=,n,m,i,j,b;
scanf("%d",&t);
while(cou<=t)
{
int ans=;
scanf("%d%d",&n,&m);
for(i=;i<n;i++)
scanf("%d",&a[i]);
for(i=;i<n;i++)
{
b=;
for(j=i;j<n;j++)
{
b|=a[j];
if(b>=m)
break;
ans++;
}
}
printf("Case #%d: %d\n",cou,ans);
cou++;
}
return ;
}
 

2013成都网络赛 J A Bit Fun(水题)的更多相关文章

  1. HDU 4737 A Bit Fun (2013成都网络赛)

    A Bit Fun Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  2. HDU 4734 F(x) (2013成都网络赛,数位DP)

    F(x) Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  3. HDU 4730 We Love MOE Girls (2013成都网络赛,签到水题)

    We Love MOE Girls Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. HDU 4733 G(x) (2013成都网络赛,递推)

    G(x) Time Limit: 2000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  5. HDU 4731 Minimum palindrome (2013成都网络赛,找规律构造)

    Minimum palindrome Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  6. 2013成都网络赛 C We Love MOE Girls(水题)

    We Love MOE Girls Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  7. 2013 长沙网络赛J题

    思路:这题对于其他能退出所有值的情况比较好像,唯一不能确定的是XXOXXOXXOXX这个形式的序列,其中XX表示未知,O表示已知. 我们令num[1]=0,那么num[4]=sum[3]-sum[2] ...

  8. HDU 4737 A Bit Fun 2013成都 网络赛 1010

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4737 题目大意:给定一系列数,F(i,j)表示对从ai到aj连续求或运算,(i<=j)求F(i, ...

  9. 2013 成都网络赛 1004 Minimum palindrome

    题目大意:用m个字母组成一个长度为N的字符串,使得最长的回文子串 的长度最小. 并且要求字典序最小. 思路:分类模拟. 当M为1 的时候就直接输出N个A 当M大于2的时候就循环ABC 当M等于2的时候 ...

随机推荐

  1. Apache、nginx配置的网站127.0.0.1可以正常访问,内外网的ip地址无法访问,谁的锅?

    最近做开发,发现一个比较尴尬的问题.因为我是一个web开发者,经常要用到Apache或者nginx等服务器软件,经过我测试发现,只要我打开了adsafe,我便不能通过ip地址访问我本地的网站了,比如我 ...

  2. Java集合框架之map

    Java集合框架之map. Map的主要实现类有HashMap,LinkedHashMap,TreeMap,等等.具体可参阅API文档. 其中HashMap是无序排序. LinkedHashMap是自 ...

  3. 用Access为支撑,书写一个用C#写入数据库的案列

    /// <summary> /// 读取Excel文档 /// </summary> /// <param name="Path">文件名称&l ...

  4. Python 过算符和数据类型

    一.算术运算符 二.逻辑运算符

  5. TinyFrame系列:基于EFCodeFirst,IOC,AOP的轻型框架

    TinyFrame开篇:基于CodeFirst的ORM TinyFrame续篇:整合Spring IOC实现依赖注入 TinyFrame再续篇:整合Spring AOP实现日志拦截 TinyFrame ...

  6. 地理信息系统 - ArcGIS - 高/低聚类分析工具(High/Low Clustering ---Getis-Ord General G)

    前段时间在学习空间统计相关的知识,于是把ArcGIS里Spatial Statistics工具箱里的工具好好研究了一遍,同时也整理了一些笔记上传分享.这一篇先聊一些基础概念,工具介绍篇随后上传. 空间 ...

  7. canvas缓动3

    这次缓动的是旋转旋转,写完之后才知道原来rotate是绕原点旋转,而且还带着rect本身的X与Y一起,所以我采用了translate达到位移效果,以免旋转到画布外面去,画完之后效果惨不忍睹,原来是忘记 ...

  8. Sokcet方式请求HTTP/HTTPS的封装类HttpHelper

    using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; ...

  9. iOS多线程学习

    在 iOS 中其实目前有 4 套多线程方案,他们分别是: Pthreads NSThread GCD NSOperation & NSOperationQueue 所以接下来,我会一一讲解这些 ...

  10. 【Codeforces710F】String Set Queries (强制在线)AC自动机 + 二进制分组

    F. String Set Queries time limit per test:3 seconds memory limit per test:768 megabytes input:standa ...