QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#390790 | #4770. Binomial coefficients | I_Love_Sonechka# | WA | 6ms | 34908kb | C++14 | 1.5kb | 2024-04-15 21:48:36 | 2024-04-15 21:48:36 |
Judging History
answer
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
// c++ short types
#define Int long long
#define vt vector
const Int inf = 1e15+1;
const int nmax = 2000;
Int dp[nmax][nmax];
map<Int, vt<tuple<int, int>>> vals;
void precalc() {
for(int n = 0; n < nmax; ++n) {
for(int k = 0; k <= n; ++k) {
if(k == 0){
dp[n][k] = 1;
} else {
dp[n][k] = dp[n-1][k] + dp[n-1][k-1];
dp[n][k] = min(dp[n][k], inf);
}
if(dp[n][k] < inf) {
vals[dp[n][k]].push_back({n, k});
}
}
}
}
void solver() {
Int m; cin >> m;
set<tuple<Int, Int>> pairs;
for(int k = 1; k <= min(10ll, m); ++k) {
Int fact = 1;
for(int i = 1; i <= k; ++i) {
fact *= 1;
}
auto f = [&](Int n) -> Int {
if(n <= k) {
return 0ll;
}
Int value = 1;
for(int i = 0; i < k; ++i) {
value *= (n-i);
if(value / fact > inf) {
return inf;
}
}
return value / fact;
};
Int l = 0, r = m + 1;
while(r - l > 1) {
Int med = (l+r)>>1;
if(f(med) <= m) {
l = med;
} else {
r = med;
}
}
if(f(l) == m) {
pairs.insert({l, k});
pairs.insert({l, l-k});
}
}
for(auto p : vals[m]) {
pairs.insert(p);
}
for(auto [a, b] : pairs) {
cout << "(" << a << "," << b << ") ";
}
cout << "\n";
}
int main()
{
precalc();
//ios::sync_with_stdio(false); cin.tie(nullptr);
int tt = 1;
cin >> tt;
for(int t = 0; t < tt; ++t) {
solver();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 6ms
memory: 34908kb
input:
2 2 15
output:
(2,1) (6,2) (6,4) (15,1) (15,14)
result:
wrong answer 1st lines differ - expected: '1', found: '(2,1) '