QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#482561#8150. XOR SumEasonLiangAC ✓27ms5360kbC++142.7kb2024-07-17 20:05:492024-07-17 20:05:49

Judging History

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

  • [2024-07-17 20:05:49]
  • 评测
  • 测评结果:AC
  • 用时:27ms
  • 内存:5360kb
  • [2024-07-17 20:05:49]
  • 提交

answer

#include <bits/stdc++.h>
#define FileIO_(file) \
    freopen (file ".in", "r", stdin); \
    freopen (file ".out", "w", stdout);

using namespace std;

template<typename Tp>
inline void chmin (Tp &x, const Tp &y) { if (y < x) x = y; }
template<typename Tp>
inline void chmax (Tp &x, const Tp &y) { if (x < y) x = y; }

typedef double dbl;
typedef long long ll;
typedef long double ldb;

void init () {}

const int maxh = 4e1 + 2;
const int maxk = 18e0 + 2;
const int maxr = 2e2 + 20;
const ll mod = 1e9 + 7;
int k;
ll n, m, binom[maxk][maxk], dp[maxh][maxr][maxk];

void trans (int h, int pr, int nr, int pc, int nc, ll tk) {
    if (maxr <= nr || nr < 0) return;
    (dp[h][nr][nc] += dp[h + 1][pr][pc] * tk) %= mod;
}

void solve () {
    scanf ("%lld%lld%d", &n, &m, &k);
    binom[0][0] = 1ll;
    for (int i = 1; i <= k; ++i) {
        binom[i][0] = 1ll;
        for (int j = 1; j <= i; ++j) {
            binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
        }
    }
    if (n >> 40 >= maxr) {
        puts ("0"); return;
    }
    dp[40][n >> 40][0] = 1ll;
    for (int i = 39; ~i; --i) {
        for (int pr = 0; pr < maxr; ++pr) {
            int nr = (pr << 1) | (n >> i & 1);
            for (int j = 0; j <= k; ++j) {
                for (int l = 0; l <= j; ++l) {
                    if (m >> i & 1) {
                        for (int c = 0, clim = k - j; c <= clim; ++c) {
                            trans (i, pr, nr - (k - l - c) * (l + c), j, j + (clim - c), binom[j][l] * binom[clim][c] % mod);
                        }
                    } else {
                        trans (i, pr, nr - (k - l) * l, j, j, binom[j][l]);
                    }
                }
            }
        }
        // for (int r = 0; r < maxr; ++r) {
        //     for (int j = 0; j <= k; ++j) {
        //         if (dp[i][r][j]) {
        //             fprintf (stderr, "%d %d %d %lld\n", i, r, j, dp[i][r][j]);
        //         }
        //     }
        // }
    }
    printf ("%lld\n", accumulate (dp[0][0], dp[0][0] + k + 1, 0ll) % mod);
}

int main () {
    // #ifndef LSY
    // FileIO_("");
    // #endif
    int t = 1; init ();
    // scanf ("%d", &t);
    while (t--) solve ();
    return 0;
}

// #ifdef LSY
// bool ed, debug = [] () {
//     static bool st; int memtyp = 0; dbl memsiz = &st - &ed;
//     static const string memstr[] = {"B", "KB", "MB", "GB"};
//     while (memsiz >= 1024.) { ++memtyp; memsiz /= 1024.; }
//     cerr << "Memory: " << memsiz << memstr[memtyp] << endl;
//     return atexit ([] () { cerr << "Time: " << 1000. *
// 		clock () / CLOCKS_PER_SEC << "ms" << endl; });
// } ();
// #endif

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 5296kb

input:

6 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

score: 0
Accepted
time: 2ms
memory: 5144kb

input:

30 6 5

output:

1520

result:

ok 1 number(s): "1520"

Test #3:

score: 0
Accepted
time: 0ms
memory: 5308kb

input:

0 0 1

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 1ms
memory: 5312kb

input:

0 0 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 1ms
memory: 5172kb

input:

0 1145141919 2

output:

145141913

result:

ok 1 number(s): "145141913"

Test #6:

score: 0
Accepted
time: 4ms
memory: 5308kb

input:

0 0 18

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 14ms
memory: 5352kb

input:

0 12412414 18

output:

12412415

result:

ok 1 number(s): "12412415"

Test #8:

score: 0
Accepted
time: 3ms
memory: 5360kb

input:

32071009996106 682053093123 12

output:

443207413

result:

ok 1 number(s): "443207413"

Test #9:

score: 0
Accepted
time: 4ms
memory: 5308kb

input:

35533005762427 688386210611 9

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 11ms
memory: 5312kb

input:

35533005762427 688386210611 18

output:

132815685

result:

ok 1 number(s): "132815685"

Test #11:

score: 0
Accepted
time: 27ms
memory: 5352kb

input:

12412412412412 549755813887 18

output:

769139144

result:

ok 1 number(s): "769139144"

Test #12:

score: 0
Accepted
time: 23ms
memory: 5236kb

input:

12412412412412 549755813887 17

output:

256540093

result:

ok 1 number(s): "256540093"

Test #13:

score: 0
Accepted
time: 17ms
memory: 5312kb

input:

12412412412412 549755813887 15

output:

661919152

result:

ok 1 number(s): "661919152"

Test #14:

score: 0
Accepted
time: 6ms
memory: 5308kb

input:

8213830533897 180838478436 12

output:

960275439

result:

ok 1 number(s): "960275439"

Test #15:

score: 0
Accepted
time: 13ms
memory: 5148kb

input:

8213830533897 180838478436 18

output:

794870059

result:

ok 1 number(s): "794870059"

Test #16:

score: 0
Accepted
time: 6ms
memory: 5292kb

input:

56737445336495 759179417237 12

output:

0

result:

ok 1 number(s): "0"

Test #17:

score: 0
Accepted
time: 15ms
memory: 5308kb

input:

56737445336495 759179417237 18

output:

302105482

result:

ok 1 number(s): "302105482"

Test #18:

score: 0
Accepted
time: 10ms
memory: 5312kb

input:

56737445336495 759179417237 15

output:

0

result:

ok 1 number(s): "0"

Test #19:

score: 0
Accepted
time: 5ms
memory: 5232kb

input:

12412412412412 274877906944 18

output:

430003400

result:

ok 1 number(s): "430003400"

Test #20:

score: 0
Accepted
time: 0ms
memory: 5220kb

input:

32412412412412 274877906944 18

output:

657686236

result:

ok 1 number(s): "657686236"

Test #21:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

562949953421311 549755813887 18

output:

0

result:

ok 1 number(s): "0"

Test #22:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

985162418487295 549755813887 18

output:

0

result:

ok 1 number(s): "0"

Test #23:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

985162418487295 962072674303 18

output:

0

result:

ok 1 number(s): "0"

Test #24:

score: 0
Accepted
time: 27ms
memory: 5348kb

input:

35184372088831 962072674303 18

output:

665848241

result:

ok 1 number(s): "665848241"

Extra Test:

score: 0
Extra Test Passed