Id | Date | User | Problem | Result | Time | Mem | Lang |
---|---|---|---|---|---|---|---|
1087 | 20/05/2013 15:16:35 | otero1991 | E - Matriz |
|
0 | 1.4 KiB | GNU G++ 5.1.0 |
#include <cstdio>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <complex>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define FOR(i,n) for (int i = 1; i <= (n); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPI(i,c) for (typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define ALL(c) c.begin(), c.end()
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define DB(x) cout << #x << " = " << x << endl;
#define CK(x) if(!(x)) cout << '(' << #x << ") is false!!!" << endl;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<int> point;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int INF = 1 << 30;
const double EPS = 1e-7;
const int MOD = 1000000007;
const int64 l = 1000000014000000049LL;
int64 pow2(int n)
{
if(n==0) return 1;
if(n%2) return (2*pow2(n-1))%MOD;
int64 k = pow2(n/2);
return (k*k)%MOD;
}
int main()
{
ios::sync_with_stdio(false);
int t; cin>>t;
while(t--)
{
int N,M; cin>>N>>M;
if(N%2 != M%2) cout<<0<<endl;
else
{
cout<<pow2((N-1)*(M-1))<<endl;
}
}
return 0;
}
//Daniel Otero Baguer (UH++)
Test 01: 0.011 0.000 1396K ok Test 02: 0.011 0.000 1400K ok Test 03: 0.011 0.000 1396K ok Test 04: 0.012 0.000 1400K ok Test 05: 0.010 0.000 1396K ok Test 06: 0.013 0.000 1400K ok Test 07: 0.011 0.000 1400K ok Test 08: 0.011 0.000 1412K ok Test 09: 0.011 0.000 1400K ok Test 10: 0.017 0.000 1396K ok Test 11: 0.010 0.000 1396K ok Accepted