Id Date User Problem Result Time Mem Lang
1087 20/05/2013 15:16:35 otero1991 E - Matriz Accepted 0 1.4 KiB GNU G++ 5.1.0
Code
x
 
1
#include <cstdio>
2
#include <sstream>
3
#include <iostream>
4
5
#include <set>
6
#include <map>
7
#include <queue>
8
#include <deque>
9
#include <vector>
10
#include <string>
11
#include <complex>
12
#include <cstring>
13
14
#include <ctime>
15
#include <cmath>
16
#include <cstdlib>
17
#include <algorithm>
18
using namespace std;
19
20
#define FOR(i,n) for (int i = 1; i <= (n); ++i)
21
#define REP(i,n) for (int i = 0; i < (n); ++i)
22
#define REPI(i,c) for (typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
23
#define ALL(c) c.begin(), c.end()
24
#define SZ(x) ((int)(x).size())
25
#define MP make_pair
26
27
#define DB(x) cout << #x << " = " << x << endl;
28
#define CK(x) if(!(x)) cout << '(' << #x << ") is false!!!" << endl;
29
30
typedef long long int64;
31
typedef unsigned long long uint64;
32
typedef complex<int> point;
33
typedef pair<int, int> pii;
34
typedef vector<int> vi;
35
36
const int INF = 1 << 30;
37
const double EPS = 1e-7;
38
const int MOD = 1000000007;
39
const int64 l = 1000000014000000049LL;
40
41
int64 pow2(int n)
42
{
43
    if(n==0) return 1;
44
    if(n%2) return (2*pow2(n-1))%MOD;
45
    int64 k = pow2(n/2);
46
    return (k*k)%MOD;
47
}
48
int main()
49
{
50
    ios::sync_with_stdio(false);
51
    int t; cin>>t;
52
    while(t--)
53
    {
54
        int N,M; cin>>N>>M;
55
        if(N%2 != M%2) cout<<0<<endl;
56
        else
57
        {
58
            cout<<pow2((N-1)*(M-1))<<endl;
59
        }
60
    }
61
    return 0;
62
}
63
//Daniel Otero Baguer (UH++)
64
Judgement Details
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