QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#235541#6425. Harmonious RectangleYangmfWA 3ms3556kbC++172.2kb2023-11-02 21:36:312023-11-02 21:36:31

Judging History

你现在查看的是最新测评结果

  • [2023-11-02 21:36:31]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3556kb
  • [2023-11-02 21:36:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
#define ld long double
#define M(x)          \
    {                 \
        x %= mod;     \
        if (x < 0)    \
            x += mod; \
    }
#define error           \
    {                   \
        cout << "No\n"; \
        return;         \
    }
#define all(x) (x.begin(), x.end())
template <typename A, typename B>
bool smax(A &a, const B &b) { return a < b ? a = b, 1 : 0; }
template <typename A, typename B>
bool smin(A &a, const B &b) { return b < a ? a = b, 1 : 0; }

const int N = 1e6 + 10;
int a[N];
int n, m, k;
const int inf = 1e18;

ld eps = 1e-9;
bool eql(ld x, ld y) { return fabs(x - y) < eps; }
bool lt(ld x, ld y) { return !eql(x, y) && x < y; }
bool rt(ld x, ld y) { return !eql(x, y) && x > y; }
int mod = 1e9 + 7;
int qpow(int x, int p)
{

    int res = 1;
    while (p)
    {

        if (p & 1)
            res = res * x % mod;
        p >>= 1;
        x = x * x % mod;
    }
    return res;
}
int ans[10][10];
void solve()
{
    int n,m;
    cin>>n>>m;
    int res=qpow(3,n*m);
    if(n>=8||m>=8){

        cout<<res<<"\n";
    } else {
        if(m>n) swap(n,m);
        cout<<ans[n][m]<<"\n";
    }
}
signed main()
{
    //freopen("D://Desktop//VSCODE//input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    ans[1][1]=0      ;
    ans[1][2]=0      ;
    ans[1][3]=0      ;
    ans[1][4]=0      ;
    ans[1][5]=0      ;
    ans[1][6]=0      ;
    ans[1][7]=0      ;
    ans[2][2]=15     ;
    ans[2][3]=339    ;
    ans[2][4]=4761   ;
    ans[2][5]=52929  ;
    ans[2][6]=517761 ;
    ans[2][7]=4767849;
    ans[3][3]=16485  ;
    ans[3][5]=14321907;
    ans[3][6]=387406809;
    ans[3][7]=460338013;
    ans[4][4]=43022385;
    ans[4][5]=486780060;
    ans[4][6]=429534507;
    ans[4][7]=792294829;
    ans[5][5]=288599194;
    ans[5][6]=130653412;
    ans[5][7]=748778899;
    ans[6][6]=246336683;
    ans[6][7]=579440654;
    ans[7][7]=236701429;
    ans[7][7]=236701429;

    while (t--)
    {

        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3556kb

input:

3
1 4
2 2
3 3

output:

0
15
16485

result:

ok 3 number(s): "0 15 16485"

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3324kb

input:

10000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 6...

output:

0
0
0
0
0
0
0
6561
19683
59049
177147
531441
1594323
4782969
14348907
43046721
129140163
387420489
162261460
486784380
460353133
381059392
143178169
429534507
288603514
865810542
597431612
792294829
376884473
130653412
391960236
175880701
527642103
582926302
748778899
246336683
739010049
217030133
6...

result:

wrong answer 8th numbers differ - expected: '0', found: '6561'