結果

問題 No.1403 調和の魔法陣
ユーザー moririn2528_cmoririn2528_c
提出日時 2021-02-20 14:51:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,359 bytes
コンパイル時間 943 ms
コンパイル使用メモリ 105,396 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 18:40:18
合計ジャッジ時間 7,442 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
#include<complex>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

long long int pow_mod(long long int a,long long int n,long long int p=1e9+7){
    //a^n mod p
    long long int b=1,t=1;
    for(;b<=n;b<<=1);
    for(b>>=1;b>0;b>>=1){
        t*=t;
        if(t>=p)t%=p;
        if(n&b)t*=a;
        if(t>=p)t%=p;
    }
    return t;
}

namespace sol{

    void init(){
        
    }

    int calc2(int a){
        return max(min(a+1,19-a),0);
    }

    LL solve(){
        int n,m,p;
        int i,j,k;
        int a,b,c;
        cin>>n>>m>>p;
        if(n%3!=2 && m%3!=2){
            if(0<=p && p<=9)return 1;
            return 0;
        }
        if(n%3!=2)swap(n,m);
        if(m%3!=2){
            n=(n+2)/3,m=(m+2)/3;
            return pow_mod(calc2(p),m,MAX);
        }
        n=(n+2)/3,m=(m+2)/3;
        LL s=0;
        for(i=0;i<10;i++){
            for(j=0;j<10;j++){
                for(k=0;k<10;k++){
                    a=p-i-j-k;
                    if(a<0 || a>=10)continue;
                    s+=pow_mod(calc2(i+j)*calc2(k+a),n-1,MAX)*pow_mod(calc2(i+k)*calc2(j+a),m-1,MAX)%MAX;
                }
            }
        }
        return s%MAX;
    }
}

int main(){
    int n,i;
    sol::init();
    cin>>n;
    for(i=0;i<n;i++){
        cout<<sol::solve()<<endl;
    }
}
0