zoukankan      html  css  js  c++  java
  • 杭电 5363 求集合的非空子集中key的数量

    Description

    soda has a set S with n integers {1,2,,n}. A set is called key set if the sum of integers in the set is an even number. He wants to know how many nonempty subsets of S are key set.
     

    Input

    There are multiple test cases. The first line of input contains an integer  , indicating the number of test cases. For each test case: 

    The first line contains an integer  , the number of integers in the set.
     

    Output

    For each test case, output the number of key sets modulo 1000000007.
     

    Sample Input

    4
    1
    2
    3
    4
     

    Sample Output

    0
    1
    3
    7
     
     
     1 #include<cstdio>
     2 __int64 f(__int64 a)
     3 {
     4     __int64 b=2;
     5     __int64 t=1;
     6     while(a)
     7     {
     8         if(a % 2 != 0)
     9         {
    10             t=(t*b)%1000000007;
    11         }
    12         b=b*b%1000000007;
    13         a/=2;
    14     }
    15     return t;
    16 }
    17 int main()
    18 {
    19     int t;
    20     scanf("%d",&t);
    21     while(t--)
    22     {
    23         __int64 n;
    24         scanf("%I64d",&n);
    25         printf("%I64d
    ",f(n-1)-1);
    26     }
    27     
    28 }
    ——将来的你会感谢现在努力的自己。
  • 相关阅读:
    Druid数据库连接池源码分析
    彻底理解Java的Future模式
    CountDownLatch与CyclicBarrier
    Semaphore实现原理分析
    ThreadLocal类分析
    Atomic类和CAS
    synchronized VS Lock, wait-notify VS Condition
    Klass与Oop
    JVM类加载以及执行的实战
    123
  • 原文地址:https://www.cnblogs.com/yexiaozi/p/5698313.html
Copyright © 2011-2022 走看看