编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#32986 #2060. 学霸题 Accepted 100 239 ms 412 K C++ 17 / 839 B admin 2025-03-22 15:11:29
显示原始代码
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 50;
int ge[maxn];
int ans[100] = { 1, 11, 55, 220, 715 };

int jia(int x) {
    int ans = 0;
    while (x) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

void solve() {
    ll k;
    cin >> k;
    if (k <= 1) {
        cout << ans[k] << endl;
        return;
    }
    if (k > 90) {
        cout << 0 << endl;
        return;
    }
    ll an = 0;
    for (int i = 0; i <= k; i++) {
        an += ge[i] * ge[k - i];
    }
    cout << an << endl;
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    // chu li
    for (int i = 0; i <= 99999; i++) {
        ge[jia(i)]++;
    }
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:4 ms
内存:412 KiB

输入文件(1.in

1
0

答案文件(1.out

1

用户输出

1

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:235 ms
内存:376 KiB

输入文件(2.in

100000
119193704883053754
139940092127619437
386274160967300890
549311792560909352
282664831212
<1985803 bytes omitted>

答案文件(2.out

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
<300442 bytes omitted>

用户输出

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

<200414 bytes omitted>

系统信息

Exited with return code 0