Submission #58509


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define read cin >>
#define echo cout <<
#define fin << '\n'
#define _ << ' ' <<
#define in :
#define var auto&&
#define let const auto
vector<int> g[1000100];
int get ( int n ) {
int ans = 0;
while ( n ) {
ans += n % 10;
n /= 10;
}
return ans;
}
int dfs ( int n ) {
int ans = g[n].size();
for ( let i in g[n] ) {
ans += dfs(i);
}
return ans;
}
signed main ( ) {
int n;
read n;
for ( int i = 1; i <= n; i++ ) {
int next = get(i) + i;
if ( next > n ) continue;
g[next].push_back(i);
}
echo dfs ( n )+1 fin;
return 0;
}

ステータス

項目 データ
問題 1267 - 桁和 (Digit Sum)
ユーザー名 r1825
投稿日時 2020-02-06 18:05:00
言語 C++14
状態 Accepted
得点 100
ソースコード長 739 Byte
最大実行時間 114 ms
最大メモリ使用量 53408 KB

セット

セット 得点 Cases
1 ALL 100 / 100 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
01-01.txt AC 72 ms 48092 KB
1
01-02.txt AC 70 ms 45660 KB
1
01-03.txt AC 39 ms 29988 KB
1
01-04.txt AC 45 ms 37680 KB
1
01-05.txt AC 76 ms 51500 KB
1
01-06.txt AC 53 ms 39920 KB
1
01-07.txt AC 67 ms 50460 KB
1
01-08.txt AC 57 ms 41588 KB
1
01-09.txt AC 82 ms 51504 KB
1
01-10.txt AC 24 ms 24016 KB
1
01-11.txt AC 22 ms 24100 KB
1
01-12.txt AC 31 ms 23932 KB
1
01-13.txt AC 29 ms 24020 KB
1
01-14.txt AC 114 ms 53408 KB
1
01-15.txt AC 93 ms 53392 KB
1
01-16.txt AC 86 ms 53400 KB
1
01-17.txt AC 77 ms 52104 KB
1
sample-01.txt AC 23 ms 24116 KB
1
sample-02.txt AC 24 ms 23944 KB
1
sample-03.txt AC 27 ms 23900 KB
1