結果
| 問題 |
No.1141 田グリッド
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-31 21:50:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 691 bytes |
| コンパイル時間 | 1,557 ms |
| コンパイル使用メモリ | 172,936 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-06 17:41:17 |
| 合計ジャッジ時間 | 5,998 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 10 |
ソースコード
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int p(int A,int B){
if(B==0)return 1;
if(B%2)return p(A,B-1)*A%mod;
int C=p(A,B/2);
return C*C%mod;
}
signed main(){
int H,W,ans=1;
cin>>H>>W;
vector<vector<int>> A(H,vector<int>(W));
vector<int> B(H,1),C(W,1);
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>A[i][j];
ans=ans*A[i][j]%mod;
B[i]=B[i]*A[i][j]%mod;
C[j]=C[j]*A[i][j]%mod;
}
}
int Q;
cin>>Q;
while(Q--){
int r,c;
cin>>r>>c;r--,c--;
cout<<ans*A[r][c]%mod*p(B[r]*C[c]%mod,mod-2)%mod<<endl;
}
}