結果
| 問題 |
No.1403 調和の魔法陣
|
| コンテスト | |
| ユーザー |
moririn2528_c
|
| 提出日時 | 2021-02-20 14:51:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,359 bytes |
| コンパイル時間 | 987 ms |
| コンパイル使用メモリ | 105,220 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-17 15:57:23 |
| 合計ジャッジ時間 | 6,467 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 19 |
ソースコード
#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;
}
}
moririn2528_c