设为首页 加入收藏

TOP

hdu 4737 A Bit Fun(TwoPointer)
2015-07-20 17:43:41 来源: 作者: 【 】 浏览:1
Tags:hdu 4737 Bit Fun TwoPointer

题目链接;hdu 4737 A Bit Fun

题目大意:给定一个长度为n的序列,现在问说有多少对i,j满足 f(i,j)

解题思路: Twopointer,将每个数拆分成二进制形式,然后维护连个指针l,r,保证f(l, r) < m,那么当i = l时,对应的j就有r - l + 1种选择方法。

#include 
   
     #include 
    
      #include 
     
       using namespace std; typedef long long ll; const int maxn = 100005; int c[35], arr[maxn]; int add (int x, int v) { int ret = 0; for (int i = 0; i <= 30; i++) { if (x&(1<
      
       = m) s = add(arr[l++], -1); ret += (i - l + 1); } return ret; } int main () { int cas; scanf("%d", &cas); for (int kcas = 1; kcas <= cas; kcas++) { ll ans = solve(); printf("Case #%d: %I64d\n", kcas, ans); } return 0; }
      
     
    
   
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Lua中面向对象编程的理解 下一篇ZOJ 3810 A Volcanic Island 构造..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·常用meta整理 | 菜鸟 (2025-12-25 01:21:52)
·SQL HAVING 子句:深 (2025-12-25 01:21:47)
·SQL CREATE INDEX 语 (2025-12-25 01:21:45)
·Shell 传递参数 (2025-12-25 00:50:45)
·Linux echo 命令 - (2025-12-25 00:50:43)