首页 > 其他 > 详细

codeforces#101194H. Great Cells(数学)

时间:2019-10-07 11:27:35      阅读:64      评论:0      收藏:0      [点我收藏+]

题目链接:

 

题意:

 

数据范围:

$1\leq |S| \leq 1000 000$

分析: 

 

AC代码:

#include<bits/stdc++.h>
#define ll long long
#define pic pair<int,char>
#define pii pair<int,int>
using namespace std;
const int maxn=3e5+7;
const int mod=1e9+7;
ll qpow(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)res=res*x%mod;
        x=x*x%mod;
        y/=2;
    }
    return res;
}
int main(){
   // cout<<qpow(2,10)<<endl;
    int T;
    scanf("%d",&T);
    for(int cn=1;cn<=T;cn++){
        int n,m,k;
        scanf("%d %d %d",&n,&m,&k);
        ll ans=qpow(k,n*m),res=0;
        for(int i=2;i<=k;i++)
            res=(res+qpow(i-1,n+m-2)*qpow(k,(n-1)*(m-1))%mod)%mod;
        ans=(ans+res*n*m%mod)%mod;
        printf("Case #%d: %lld\n",cn,ans);
    }
    return 0;
}

  

codeforces#101194H. Great Cells(数学)

原文:https://www.cnblogs.com/carcar/p/11629560.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!