zoukankan      html  css  js  c++  java
  • 2018icpc徐州OnlineA Hard to prepare

    src:https://nanti.jisuanke.com/t/31453

    解答传送门

    ac代码:

    #include<bits/stdc++.h>
    #define per(i,a,b) for(int i=a;i<=b;i++)
    #define mod 1000000007
    using namespace std;
    typedef long long ll;
    //#define int long long
    const int inf =0x3f3f3f3f;
    const double eps=1e-8;
    int read(){
        char ch=getchar();
        int res=0,f=0;
        while(ch<'0' || ch>'9'){f=(ch=='-'?-1:1);ch=getchar();}
        while(ch>='0'&&ch<='9'){res=res*10+(ch-'0');ch=getchar();}
        return res*f;
    }
    // ------------------------head
    const int siz=1000005;
    int T,n,k;
    ll mi[siz]={1};
    ll _pow(ll a,ll b){
        ll res=1;
        while(b){
            if(b%2==1)res=res*a%mod;
            a=a*a%mod;
            b/=2;
        }
        return res;
    }
    ll fun(int a,int b){
        if(a==2)return mi[b]*(mi[b]-1)%mod;
        if(a==1)return mi[b];
        ll ans=(mi[b]*_pow(mi[b]-1,a-2)%mod*max((mi[b]-2),0ll)%mod+fun(a-2,b))%mod;
        return ans;
    }
    signed main()
    {
        scanf("%d",&T);
        per(i,1,1000002){mi[i]=mi[i-1]*2%mod;}
        while(T--){
            scanf("%d %d",&n,&k);
            printf("%lld
    ",fun(n,k)%mod);
        }
    
        return 0;
    }
  • 相关阅读:
    vijos 1426
    2455 繁忙的都市
    2104 删除物品
    3235 战争
    BZOJ 2962
    COGS 265 线段覆盖
    P2184 贪婪大陆
    0729模拟赛解题报告
    BZOJ 1012
    BZOJ 2763
  • 原文地址:https://www.cnblogs.com/WindFreedom/p/9645703.html
Copyright © 2011-2022 走看看