QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#390794 | #4770. Binomial coefficients | I_Love_Sonechka# | WA | 5ms | 27864kb | C++14 | 1.5kb | 2024-04-15 21:49:27 | 2024-04-15 21:49:27 |
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);
}
cout << pairs.size() << "\n";
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 5ms
memory: 27544kb
input:
2 2 15
output:
1 (2,1) 4 (6,2) (6,4) (15,1) (15,14)
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 27864kb
input:
100 2 3 4 5 6 7 8 9 10 15 120 3003 24310 495918532948104 1000000000000000 210 1540 2701 7140 11628 48620 614386 705432 817190 885115 4200651 4610166 5311735 5918520 6299475 6666891 6876486 7023974 7610851 8002000 8948565 9016381 9411291 9695406 30421755 1676056044 9075135300 101766230790 13784652882...
output:
1 (2,1) 2 (3,1) (3,2) 2 (4,1) (4,3) 2 (5,1) (5,4) 5 (3,1) (3,2) (4,2) (6,1) (6,5) 2 (7,1) (7,6) 2 (8,1) (8,7) 2 (9,1) (9,8) 4 (5,2) (5,3) (10,1) (10,9) 4 (6,2) (6,4) (15,1) (15,14) 9 (5,1) (5,4) (6,3) (10,3) (10,7) (16,2) (16,14) (120,1) (120,119) 8 (14,6) (14,8) (15,5) (15,10) (78,2) (78...
result:
wrong answer 9th lines differ - expected: '3', found: '5'