zoukankan      html  css  js  c++  java
  • 组队 (Teams,UVa 11609)

     1 #include <iostream>
     2 #include <string.h>
     3 #include <string>
     4 #include <fstream>
     5 #include <algorithm>
     6 #include <stdio.h>
     7 #include <vector>
     8 #include <queue>
     9 #include <set>
    10 #include <cmath>
    11 using namespace std;
    12 const double eps = 1e-8;
    13 const int INF=0x7fffffff;
    14 unsigned long long uINF = ~0LL;
    15 #define MAXN 10000007
    16 typedef long long LL;
    17 LL vis[MAXN];
    18 LL prime[MAXN];
    19 
    20 void sieve(LL n)
    21 {
    22     LL m=(LL)sqrt(n+0.5);
    23     memset(vis,0,sizeof(vis));
    24     for(LL i=2;i<=m;i++)if(!vis[i])
    25     for(LL j=i*i;j<=n;j+=i)vis[j]=1;
    26 }
    27 
    28 LL gen_prime(LL n)
    29 {
    30     sieve(n);
    31     LL c=0;
    32     for(LL i=2;i<=n;i++)if(!vis[i])
    33         prime[c++]=i;
    34     return c;
    35 }
    36 
    37 LL gcd(LL a,LL b)
    38 {
    39     return b==0?a:gcd(b,a%b);
    40 }
    41 
    42 LL pow_mod(LL a,LL n,LL m)
    43 {
    44     if(n==0)return 1;
    45     LL x=pow_mod(a,n/2,m);
    46     LL ans=x*x%m;
    47     if(n%2==1)ans=ans*a%m;
    48     return ans;
    49 }
    50 
    51 int main()
    52 {
    53     int T,t=1;
    54     scanf("%d",&T);
    55     LL n;
    56     while(T--)
    57     {
    58         scanf("%lld",&n);
    59         LL ans=pow_mod(2,n-1,1000000007);
    60         ans=ans*n%1000000007;
    61         printf("Case #%d: %lld
    ",t++,ans);
    62     }
    63 
    64     return 0;
    65 }

    ans=n* 2^(n-1);

  • 相关阅读:
    对拍
    浅谈trie树
    蒟蒻的二分模板
    浅谈线性素数筛
    浅谈树状数组
    HDU 2181 哈密顿绕行世界问题
    HDU 3567 Eight II
    HDU 1043 Eight
    POJ 3076 Sudoku
    hihoCoder 1087 Hamiltonian Cycle
  • 原文地址:https://www.cnblogs.com/TO-Asia/p/3204996.html
Copyright © 2011-2022 走看看