Gym 101194 thinking count

The question I really have no idea at first glance ah. . . What are the summation of a bunch of things, how to calculate the impact of each head really want to have to die, I feel is a thinking problem, I might have done that too little of it, can not think of the equation apart, the problem is to g and 1 open look, the key is this number multiplied by g Ag, that is to say, there is a good case g g grid considered contributions, this place is critical: this is equivalent to a good grid It corresponds to a contribution of value, that is, you are a good lattice grid, no matter how the other options, its contribution has been 1, so you calculate the contribution of each grid on the line, this a good grid, with listed peers restrictions, any other on it. Dry, this question could be so simple I will not, in fact, features a very obvious, there is a factor which is the number of g, there must be something wrong, the trail has been placed on the face, ah! ! ! mmp, not counting in the middle of n == 1 and m == 1. wrong, is not considered even by the explosion ll wrong again, next time pay attention! ! !

#include<iostream>
#include<cstring>
#include <string>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#define lson rt<<1
#define rson rt<<1|1
using namespace std;
typedef long long ll;
const int maxn=1e5+20;
const int mod=1e9+7;
typedef unsigned long long ull;
typedef long long ll;
ll ans;
ll n,k,m;
int main()
{
    int T,num=1;
    cin>>T;
    while(T--)
    {
        cin>>n>>m>>k;
        if(n==1&&m==1)
        {
            ans=k*2;
            cout<<"Case #"<<num++<<": "<<ans<<endl;
            continue;
        }
        ll ans=1,tt=1;
        for(int i=0;i<n*m;i++)
            ans=(ans*k)%mod;
        for(int i=0;i<(n-1)*(m-1);i++)
            tt=(tt*k)%mod;
        
        for(int i=2;i<=k;i++)
        {
            ll t=1;
            for(int j=0;j<n-1;j++)
                t=t*(i-1)%mod;
            for(int j=0;j<m-1;j++)
                t=t*(i-1)%mod;
            ans=(ans+((t*m*n)%mod)*tt)%mod;
        }
        cout<<"Case #"<<num++<<": "<<ans<<endl;
    }
}

 

Guess you like

Origin www.cnblogs.com/King-of-Dark/p/11621968.html