Code Festival C Div and Add

Submit

Your name:
File:
Open code-statistics:

Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.

Problem

This is an entry for <a href="http://codefestival.jp/">Code Festival</a>. See below for some English.

この問題は <a href="http://recruit-jinji.jp/code_fes2015/short.html">Code Festival 「短縮王」</a>のための問題です。 CODE FESTIVAL本戦参加者の方は、会場で配布されている、ルールブック記載のURLにてご解答ください。

以下問題の原文です

<pre>
C - 割り算と足し算

問題文
正の整数 N が与えられます。N を 1 になるまで約数で割っていって数列を作ります。数列の各要素の各位の和の総和を最大化してください。

例えば、N=12 の場合、12,6,3,1 という数列を作ると 1+2+6+3+1=13 となり、これが最大です。

入力
入力は以下の形式で標準入力から与えられる。

N
整数 N(1≦N≦100) が 1 行で与えられる。
出力
答えを出力せよ。出力の末尾に改行を入れること。
</pre>

これは非公式な本来の問題のコピーです。ゴルフ場の仕様にあわせるため、問題は1テストケース1行の形式で与えられ、各行に1つのテストケースの入力が与えられます。ゴルフ場で良い成績が出たから本番でもそのまま通るとは限りません。特にこの問題は入力の形式の違いによりかなり違うコードが本番で必要な可能性があります。表彰されるためには本来のサイトで投稿する必要があります。投稿サイトは後日ここからリンクをはる予定です。

普段からこのサイトに参加している人へ: 普通に解答を投稿してくれて良いです。ただし状況に応じて問題の更新や解答のリセットなどをするかもしれません。11月16日以降は普通の問題になるはずです。

Given a number N, you'll need to divide it by positive numbers until the number is 1. The goal is to maximize the sum of digits appeared in this process. For example, for N=12 you'll see 12, 6 3, 1 and the sum of digits will be 1+2+6+3+1=13 and this is the maximum number.

For golfers in this site: feel free to submit solutions as usual. Please just understand the problem may be updated and your solutions may be rejudged. No update will be done after Nov. 16.

Personal note: unlike usual, I may examine submitted solutions even before the deadline (I've never done this, trust me :), potentially to introduce interesting techniques in the event. As usual, I can promise I don't abuse the knowledge got in this way.

Options

exec is denied

now post-mortem time, all source codes will be revealed

Sample input:_

12
1
100

Sample output:

13
1
19

Sample input:_

38
30
88
56
11
15
27
35
14
18
100
99
68
16
49
69
54
9
61
8
24
81
40
47
60
72
78
83
85
75
5
90
84
89
21
22
39
48
2
96
12
95
25
4
43
64
1
19
26
67
94
10
44
65
36
55
42
77
41
29
6
32
51
87
7
92
63
98
58
46
33
28
66
20
57
80
97
52
45
86
73
62
23
17
82
53
59
79
13
34
50
91
31
76
74
93
3
37
71
70

Sample output:

22
15
31
34
3
12
22
16
13
22
19
31
30
22
21
21
31
13
8
15
21
31
19
12
21
40
32
12
22
25
6
31
35
18
11
7
17
34
3
49
13
25
13
7
8
37
1
11
13
14
25
7
15
17
31
16
19
22
6
12
10
27
15
27
8
27
22
38
25
16
10
23
22
9
23
30
17
20
22
22
11
13
6
9
16
9
15
17
5
16
18
18
5
35
22
17
4
11
9
23

Ranking

Ruby _

RankUserSizeTimeDateStatistics
1mitchs770.06982015/11/16 03:29:050B / 38B / 38B
2kimiyuki920.90402015/11/13 20:13:100B / ?B / ?B
3siman940.05082015/11/13 21:09:280B / 44B / 47B
4hirokazu10201000.06222015/11/13 23:25:470B / ?B / ?B
5ciel1110.05332015/11/12 00:44:200B / ?B / ?B
6mitchs (embed)1210.03992015/11/18 06:21:2085B / 14B / 14B
7mitchs_ (embed)1260.02612015/11/11 03:52:4888B / 9B / 21B
8shinh (par)1600.06792015/11/10 23:41:060B / 91B / 45B

Ruby2 _

RankUserSizeTimeDateStatistics
1mitchs730.16842015/11/16 03:30:590B / 34B / 38B
2shinh750.14752015/11/14 03:15:030B / 39B / 35B
3kimiyuki930.41322015/11/13 19:41:250B / ?B / ?B
4siman940.14422015/11/13 21:09:130B / 44B / 47B
5ciel1110.13802015/11/12 00:48:470B / ?B / ?B

Perl _

RankUserSizeTimeDateStatistics
1llhuii660.05012015/11/15 10:33:511B / 18B / 46B
2tails720.63542015/11/14 21:51:380B / 24B / 47B
3kimiyuki1140.02382015/11/13 19:58:280B / ?B / ?B

Python _

RankUserSizeTimeDateStatistics
1mitchs910.08632015/11/16 03:56:190B / 58B / 26B

PARI/GP _

RankUserSizeTimeDateStatistics
1mitchs800.03932015/11/24 08:38:110B / 48B / 31B
2mitchs780.04332015/11/25 13:53:060B / 46B / 32B

J _

RankUserSizeTimeDateStatistics
1I., S.550.10682015/11/18 13:05:230B / 15B / 40B

C _

RankUserSizeTimeDateStatistics
1llhuii1140.02132015/11/14 17:38:380B / 56B / 58B
2mitchs1240.02172015/11/16 03:34:140B / 67B / 56B
3ciel1360.02462015/11/24 19:01:280B / ?B / ?B
4shinh1380.02152015/11/14 11:31:210B / 69B / 68B
5orisano1480.02152015/11/14 10:45:120B / ?B / ?B
6cympfh1790.02152015/11/14 01:58:550B / 91B / 85B
7mitchs (llhuii)1130.02132015/11/25 13:42:220B / 55B / 58B

C++ _

RankUserSizeTimeDateStatistics
1ciel1720.02572015/11/24 19:12:350B / ?B / ?B

Haskell _

RankUserSizeTimeDateStatistics
1henkma940.03142015/11/24 20:01:510B / 56B / 30B

ObjC _

RankUserSizeTimeDateStatistics
1llhuii1140.02122015/11/24 00:07:540B / 56B / 58B
2ciel1360.02132015/11/24 19:04:330B / ?B / ?B

AWK _

RankUserSizeTimeDateStatistics
1llhuii760.03582015/11/24 01:28:270B / 34B / 42B
2mitchs (llhuii)750.03632015/11/25 14:42:370B / 33B / 42B

sed _

RankUserSizeTimeDateStatistics
1tails (embed)2280.02532015/11/16 10:40:380B / 168B / 52B
2tails2690.05052015/11/16 10:21:100B / 191B / 64B
3mitchs (tails (embed))2150.02122016/02/20 12:53:090B / 165B / 39B

Bash _

RankUserSizeTimeDateStatistics
1llhuii820.03392015/11/24 22:09:580B / 37B / 44B

Zsh _

RankUserSizeTimeDateStatistics
1llhuii820.05132015/11/24 22:10:050B / 37B / 44B

Fish _

RankUserSizeTimeDateStatistics
1llhuii820.07602015/11/24 22:10:100B / 37B / 44B

xgawk _

RankUserSizeTimeDateStatistics
1llhuii790.04442015/11/24 01:42:130B / 35B / 44B

GolfScript _

RankUserSizeTimeDateStatistics
1whio910.13392015/11/11 07:27:0644B / 21B / 25B

gs2 _

RankUserSizeTimeDateStatistics
1whio190.73662015/11/12 01:08:318B / 8B / 2B

Language Ranking_

RankLangUserSizeScore
1gs2whio1910000
2JI., S.553454
3Perlllhuii662878
4Ruby2mitchs732602
5AWKmitchs (llhuii)752533
6Rubymitchs772467
7PARI/GPmitchs782435
8xgawkllhuii792405
9Bashllhuii822317
10Zshllhuii822317
11Fishllhuii822317
12GolfScriptwhio912087
13Pythonmitchs912087
14Haskellhenkma942021
15Cmitchs (llhuii)1131681
16ObjCllhuii1141666
17C++ciel1721104
18sedmitchs (tails (embed))215883

return to the top page