zoukankan      html  css  js  c++  java
  • uoj#300.【CTSC2017】吉夫特

    题面:http://uoj.ac/problem/300

    一道大水题,然而我并不知道$lucas$定理的推论。。

    $inom{n}{m}$为奇数的充要条件是$n&m=n$。那么我们对于每个数,直接枚举子集转移就行了,复杂度是$O(3^{18})$,不会$T$。

     1 //It is made by wfj_2048~
     2 #include <algorithm>
     3 #include <iostream>
     4 #include <complex>
     5 #include <cstring>
     6 #include <cstdlib>
     7 #include <cstdio>
     8 #include <vector>
     9 #include <cmath>
    10 #include <queue>
    11 #include <stack>
    12 #include <map>
    13 #include <set>
    14 #define rhl (1000000007)
    15 #define inf (1<<30)
    16 #define N (300010)
    17 #define il inline
    18 #define RG register
    19 #define ll long long
    20 #define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
    21 
    22 using namespace std;
    23 
    24 int f[N],a[N],b[N],n,ans;
    25 
    26 il int gi(){
    27     RG int x=0,q=1; RG char ch=getchar();
    28     while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
    29     if (ch=='-') q=-1,ch=getchar();
    30     while (ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar();
    31     return q*x;
    32 }
    33 
    34 il void work(){
    35     n=gi(); for (RG int i=1;i<=n;++i) a[i]=gi(),b[a[i]]=i;
    36     for (RG int i=1;i<=n;++i){
    37     ans+=(f[i]++); if (ans>=rhl) ans-=rhl;
    38     for (RG int s=a[i];s;s=(s-1)&a[i])
    39         if (b[s]>i){ f[b[s]]+=f[i]; if (f[b[s]]>=rhl) f[b[s]]-=rhl; }
    40     }
    41     printf("%d
    ",ans); return;
    42 }
    43 
    44 int main(){
    45     File("gift");
    46     work();
    47     return 0;
    48 }
  • 相关阅读:
    Codeforces 963E Alternating Sum 等比数列+逆元
    poj 3255 次短路
    hdu 3183 rmq+鸽巢原理
    poj 2505 乘法博弈论
    欧拉函数模板
    java中的进制转换以及字符串类和数值类的相互转化
    java 大数运算,高精度模板
    线段树模板
    [OI笔记]每周刷题记录
    HDU4388-Stone Game II-Nim变形
  • 原文地址:https://www.cnblogs.com/wfj2048/p/6915527.html
Copyright © 2011-2022 走看看