[PYTHON] Codeforces Beta Round # 13

Yes. A. Numbers implementation,math

Roughly the meaning

-Average of the total number of digits to write from binary to A-1? ??

Something like a policy

・ Generate an n-ary expression.

Note (description of the first sample case)

・ 5 is expressed from binary to quaternary. · Binary: 101 ternary: 12 quaternary: 11 The sum of each digit is 2,3,2

a.py


#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import time
import sys, io
import re, math
start = time.clock()
a=int(raw_input())
s=0
for n in range(2,a):
    c=a
#Add the remainder to s.(I want to know the sum, so I don't need to save the order)
#c continues to substitute the quotient.
    while c:s+=c%n;c/=n
x,y=s,a-2
while y:x,y=y,x%y
print str(s/x) +'/'+ str((a-2)/x)

How to convert a number given in decimal to n It is like this. http://www.nowshika.com/joso/img01010112.png

Recommended Posts

Codeforces Beta Round # 13
Codeforces Beta Round # 1
Codeforces Beta Round # 2
Codeforces Round # 679 (Div. 2) Review (10/25)
Codeforces Round # 657 (Div. 2) Review
Codeforces Round # 658 (Div. 2) Bacha Review (7/29)
Educational Codeforces Round 93 Bacha Review (8/17)
Codeforces Round # 609 (Div. 2) Bacha Review (10/8)
Educational Codeforces Round 94 Bacha Review (9/3)
Educational Codeforces Round 91 Bacha Review (7/28)
Codeforces Round # 666 (Div. 2) Bacha Review (9/2)
Codeforces Round # 651 (Div. 2) Bacha Review (8/20)
Codeforces Round # 659 (Div. 2) Bacha Review (8/5)
Codeforces Round # 610 (Div. 2) Bacha Review (10/5)
Codeforces Round # 479 (Div. 3) Bacha Review (9/25)
Codeforces Round # 603 (Div. 2) Bacha Review (10/15)
Codeforces Round # 639 (Div. 2) Bacha Review (9/4)
Codeforces Round # 612 (Div. 2) Bacha Review (10/2)
Codeforces Round # 521 (Div. 3) Bacha Review (10/9)
Codeforces Round # 652 (Div. 2) Bacha Review (8/24)
Codeforces Round # 673 (Div. 2) Bacha Review (10/22)
Codeforces Round # 606 (Div. 3) Bacha Review (10/13)
Codeforces Round # 665 (Div. 2) Bacha Review (8/23)
Codeforces Round # 592 (Div. 2) Bacha Review (11/03)
Codeforces Round # 662 (Div. 2) Bacha Review (8/8)
Codeforces Round # 618 (Div. 2) Bacha Review (9/26)
Codeforces Round # 648 (Div. 2) Bacha Review (9/5)
Codeforces Round # 676 (Div. 2) Bacha Review (10/31)
Codeforces Round # 675 (Div. 2) Bacha Review (10/30)
Codeforces Round # 486 (Div. 3) Bacha Review (9/23)
Codeforces Round # 671 (Div. 2) Bacha Review (9/22)
Educational Codeforces Round 89 Bacha Review (9/8)
Codeforces Round # 669 (Div. 2) Bacha Review (9/9)
Codeforces Round # 672 (Div. 2) Bacha Review (10/16)
Codeforces Round # 638 (Div. 2) Bacha Review (9/16)
Codeforces Round # 663 (Div. 2) Bacha Review (8/13)
Educational Codeforces Round 92 Bacha Review (7/30)
Codeforces Round # 668 (Div. 2) Bacha Review (9/7)
Codeforces Round # 626 B. Count Subrectangles
Codeforces Round # 663 (Div. 2) Bacha Review (8/16)
Codeforces Round # 609 (Div. 2) Bacha Review (10/6)
Codeforces Round # 645 (Div. 2) Bacha Review (9/10)
Educational Codeforces Round 90 Bacha Review (8/19)
Codeforces Round # 664 (Div. 2) Bacha Review (8/13)
Codeforces Round # 660 (Div. 2) Bacha Review (8/4)
Codeforces Round # 609 (Div. 2) (up to B)