QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#701784#8150. XOR SumHHAZWA 0ms3960kbC++202.8kb2024-11-02 14:42:472024-11-02 14:42:49

Judging History

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

  • [2024-11-02 14:42:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3960kb
  • [2024-11-02 14:42:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
typedef pair<ld,ld>pdd;
typedef pair<ll, pair<ll, ll> > plpair;
typedef vector<int> vi;
typedef vector<ll> vl;
#define endl '\n'
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
#define debug(x) cout<<#x<<": "<<x<<endl
#define lowbit(id) id & (-id)
#define fi first
#define sec second
#define lc id<<1
#define rc id<<1|1
#define sz(x) (int)(x).size()
#define all(t) (t).begin(), (t).end()
#define meh {cout<<"NO"<<endl;return;}
#define yay {cout<<"YES"<<endl;return;}
#define vin(v) for(auto&x:v)cin>>x;
#define print(v) for (auto x: v)cout<<x<<' ';cout<<endl;
#define sqrt(x) sqrtl(x)
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 2e3 + 5;
const ll M = 2e3 + 1;
const ll D = 101;
const ll mod = 1e9 + 7;
const ll MAX = 1e18;

ll c[20][20], a[65], id, n, m, k, pw2[20];
unordered_map<ll, ll>dp[65][20];
void init_combinatorial(ll Mod)
{
    for(int i=0;i<19;i++) c[i][0]=1;
    for(int i=1;i<19;i++)
    {
        for(int j=1;j<=i;j++)
        {
            c[i][j]=(c[i-1][j]+c[i-1][j-1])%Mod;
        }
    }
}

ll dfs(ll w, ll lim, ll need) {
    if(w < 0) return (need == 0);
    if(need < 0) return 0;
    if(dp[w][lim].count(need)) return dp[w][lim][need];
    ll ans = 0;
    if(a[w]) {
        rep(i, 0, lim) {
            rep(j, 0, k - lim) {
                ans += c[lim][i] * c[k - lim][j] % mod * dfs(w - 1, i, need - (i + j) * (k - i - j) * pw2[w]) % mod;
                ans %= mod;
            }
        }
    }
    else {
        rep(i, 0, k - lim) {
            ans += c[k - lim][i] * dfs(w - 1, lim, need - i * (k - i) * pw2[w]) % mod;
            ans %= mod;
        }
    }
    dp[w][lim][need] = ans;
    return ans;
}

void solve() {
    init_combinatorial(mod);
    pw2[0] = 1;
    rep(i, 1, 19) {
        pw2[i] = pw2[i - 1] * 2;
    }
    cin >> n >> m >> k;
    while(m) {
        a[id++] = m & 1;
        m /= 2;
    }
    cout << dfs(id - 1, k, n) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int T = 1;
//	cin >> T;
	//	cout.flush();
	//		ofstream outfile("C:\\Users\\86187\\OneDrive\\桌面\\1.txt");
	//		outfile << "a[1]=0;a[2]=1;";
	//		ll l = 1e7 + 1;
	//		rep(i, 3, 1e9) {
	//			printf("%lld\n", i);
	//			ll x = (i - 1) * ((a[i - 1] + a[i - 2]) % mod);
	//			x %= mod;
	//			if(i == l) {
	//				outfile << "a[" << i << "]=" << x << ";";
	//			}
	//			if(i == l + 1) {
	//				outfile << "a[" << i << "]=" << x << ";";
	//				l += 1e7;
	//			}
	//		}
	while(T--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

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

input:

30 6 5

output:

1520

result:

ok 1 number(s): "1520"

Test #3:

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

input:

0 0 1

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

0 0 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3960kb

input:

0 1145141919 2

output:

9644762

result:

wrong answer 1st numbers differ - expected: '145141913', found: '9644762'