QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#310079#8150. XOR Sumbachbeo2007AC ✓114ms6732kbC++232.8kb2024-01-21 01:22:152024-01-21 01:22:15

Judging History

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

  • [2024-01-21 01:22:15]
  • 评测
  • 测评结果:AC
  • 用时:114ms
  • 内存:6732kb
  • [2024-01-21 01:22:15]
  • 提交

answer

// Judges with GCC >= 12 only needs Ofast
// #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize")
// MLE optimization
// #pragma GCC optimize("conserve-stack")
// Old judges
// #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2")
// New judges. Test with assert(__builtin_cpu_supports("avx2"));
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// Atcoder
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma")
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
- insert(x),erase(x)
- find_by_order(k): return iterator to the k-th smallest element
- order_of_key(x): the number of elements that are strictly smaller
*/

#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_real_distribution<> pp(0.0,1.0);
#define int long long
#define ld long double
#define pii pair<int,int>
#define piii pair<pii,int>
#define mpp make_pair
#define fi first
#define se second
const int inf=1e18;
const int mod=1e9+7;
const int maxn=35;
const int bl=650;
const int maxs=655;
const int maxm=200005;
const int maxq=1000005;
const int maxl=20;
const int maxa=1000000;
const int root=3;
int power(int a,int n){
    int res=1;
    while(n){
        if(n&1) res=res*a%mod;
        a=a*a%mod;n>>=1;
    }
    return res;
}
const int iroot=power(3,mod-2);
const int base=101;

int fac[maxn],dfac[maxn];
int C(int n,int k){
    if(k>n) return 0;
    return fac[n]*dfac[k]%mod*dfac[n-k]%mod;
}
void combi(int n){
    fac[0]=1;
    for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
    dfac[n]=power(fac[n],mod-2);
    for(int i=n;i>=1;i--) dfac[i-1]=dfac[i]*i%mod;
}

int n,m,k;
map<int,int> mp[65][20];

int f(int total,int x,int cnt){
    if(x==-1) return total==0;
    if(total>(k/2)*(k-k/2)*((1LL<<(x+1))-1)) return 0;
    if(mp[x][cnt].find(total)!=mp[x][cnt].end()) return mp[x][cnt][total];
    int res=0;
    if(m>>x&1){
        for(int i=0;i<=cnt;i++) for(int j=0;j<=k-cnt;j++){
            int num=(i+j)*(k-i-j)*(1LL<<x);
            if(total>=num) res=(res+f(total-num,x-1,i)*C(k-cnt,j)%mod*C(cnt,i))%mod;
        }
    }
    else{
        for(int i=0;i<=k-cnt;i++){
            int num=i*(k-i)*(1LL<<x);
            if(total>=num) res=(res+f(total-num,x-1,cnt)*C(k-cnt,i))%mod;
        }
    }
    return mp[x][cnt][total]=res;
}

void solve(){
    cin >> n >> m >> k;
    combi(k);
    cout << f(n,49,k) << '\n';
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int test=1;//cin >> test;
    while(test--) solve();
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

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

input:

30 6 5

output:

1520

result:

ok 1 number(s): "1520"

Test #3:

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

input:

0 0 1

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

0 0 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

0 1145141919 2

output:

145141913

result:

ok 1 number(s): "145141913"

Test #6:

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

input:

0 0 18

output:

1

result:

ok 1 number(s): "1"

Test #7:

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

input:

0 12412414 18

output:

12412415

result:

ok 1 number(s): "12412415"

Test #8:

score: 0
Accepted
time: 7ms
memory: 4408kb

input:

32071009996106 682053093123 12

output:

443207413

result:

ok 1 number(s): "443207413"

Test #9:

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

input:

35533005762427 688386210611 9

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 47ms
memory: 6432kb

input:

35533005762427 688386210611 18

output:

132815685

result:

ok 1 number(s): "132815685"

Test #11:

score: 0
Accepted
time: 114ms
memory: 6732kb

input:

12412412412412 549755813887 18

output:

769139144

result:

ok 1 number(s): "769139144"

Test #12:

score: 0
Accepted
time: 32ms
memory: 5052kb

input:

12412412412412 549755813887 17

output:

256540093

result:

ok 1 number(s): "256540093"

Test #13:

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

input:

12412412412412 549755813887 15

output:

661919152

result:

ok 1 number(s): "661919152"

Test #14:

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

input:

8213830533897 180838478436 12

output:

960275439

result:

ok 1 number(s): "960275439"

Test #15:

score: 0
Accepted
time: 53ms
memory: 6496kb

input:

8213830533897 180838478436 18

output:

794870059

result:

ok 1 number(s): "794870059"

Test #16:

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

input:

56737445336495 759179417237 12

output:

0

result:

ok 1 number(s): "0"

Test #17:

score: 0
Accepted
time: 50ms
memory: 6436kb

input:

56737445336495 759179417237 18

output:

302105482

result:

ok 1 number(s): "302105482"

Test #18:

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

input:

56737445336495 759179417237 15

output:

0

result:

ok 1 number(s): "0"

Test #19:

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

input:

12412412412412 274877906944 18

output:

430003400

result:

ok 1 number(s): "430003400"

Test #20:

score: 0
Accepted
time: 9ms
memory: 5624kb

input:

32412412412412 274877906944 18

output:

657686236

result:

ok 1 number(s): "657686236"

Test #21:

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

input:

562949953421311 549755813887 18

output:

0

result:

ok 1 number(s): "0"

Test #22:

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

input:

985162418487295 549755813887 18

output:

0

result:

ok 1 number(s): "0"

Test #23:

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

input:

985162418487295 962072674303 18

output:

0

result:

ok 1 number(s): "0"

Test #24:

score: 0
Accepted
time: 112ms
memory: 6644kb

input:

35184372088831 962072674303 18

output:

665848241

result:

ok 1 number(s): "665848241"

Extra Test:

score: 0
Extra Test Passed