编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#25337 #1140. ddd和骡马 Accepted 100 38 ms 648 K C++ / 796 B hujilin 2020-04-26 11:21:56
显示原始代码
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = 100000;
int a[maxn];

int jiecheng(long long x) {
    if (x == 0)
        return 1;
    return x * jiecheng(x - 1);
}

void calculate(int x) {
    int a1 = x / 100000;
    int a2 = (x % 100000) / 10000;
    int a3 = (x % 10000) / 1000;
    int a4 = (x % 1000) / 100;
    int a5 = (x % 100) / 10;
    int a6 = x % 10;
    a[x] = (a1 + a2 + a3 + a4 + a5 + a6);
}

int main() {
    long long n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        calculate(i);
        // cout<<a[i]<<endl;
    }
    long long sum = 0;
    for (int i = 1; i <= 45; i++) {
        long long k = 0;
        for (int j = 1; j <= n; j++) {
            if (a[j] == i)
                k++;
        }
        // cout<<k<<endl;
        if (k > 1)
            sum += k * (k - 1);
        // cout<<sum<<endl;
    }
    sum += n;
    cout << sum;

    return 0;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:2 ms
内存:280 KiB

输入文件(1.in

62

答案文件(1.out

328

用户输出

328

系统信息

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

输入文件(2.in

712

答案文件(2.out

30968

用户输出

30968

系统信息

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

输入文件(3.in

2663

答案文件(3.out

403601

用户输出

403601

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:3 ms
内存:352 KiB

输入文件(4.in

6306

答案文件(4.out

2108470

用户输出

2108470

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:3 ms
内存:368 KiB

输入文件(5.in

12489

答案文件(5.out

7534405

用户输出

7534405

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:3 ms
内存:392 KiB

输入文件(6.in

21533

答案文件(6.out

22208009

用户输出

22208009

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:4 ms
内存:488 KiB

输入文件(7.in

34247

答案文件(7.out

56739967

用户输出

56739967

系统信息

Exited with return code 0
测试点 #8
Accepted
得分:100
用时:5 ms
内存:488 KiB

输入文件(8.in

51144

答案文件(8.out

122757374

用户输出

122757374

系统信息

Exited with return code 0
测试点 #9
Accepted
得分:100
用时:6 ms
内存:612 KiB

输入文件(9.in

72839

答案文件(9.out

243907943

用户输出

243907943

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:7 ms
内存:648 KiB

输入文件(10.in

99960

答案文件(10.out

432430482

用户输出

432430482

系统信息

Exited with return code 0