QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#235552#6425. Harmonious RectangleYangmfWA 2ms3572kbC++172.2kb2023-11-02 21:43:312023-11-02 21:43:31

Judging History

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

  • [2023-11-02 21:43:31]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3572kb
  • [2023-11-02 21:43: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==1||m==1){

        cout<<0<<"\n";
        return;
    }
    if(n>=8||m>=8){

        cout<<res<<"\n";
    } else {
        if(m>n) swap(n,m);
        cout<<ans[n][m]<<"\n";
    }
}
signed main()
{

    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;

    while (t--)
    {

        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3572kb

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: 2ms
memory: 3556kb

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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
15
0
0
0
0
0
43046721
387420489
486784380
381059392
429534507
865810542
792294829
130653412
175880...

result:

wrong answer 103rd numbers differ - expected: '339', found: '0'