用户输出
328
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#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;
}