Problem:


Problem A: 雅先生の地球侵略日誌

クァークゴ帝国遠征軍は、地球侵略をもくろむ悪の組織である。彼らは侵略者の伝統にのっとり、日
本の東京周辺をターゲットに、毎週１体のペースで怪人を送りこみ続けていた。しかし、そのたびに
人類戦隊アースファイブと名乗る５人の戦士があらわれ、街で暴れまわっていた怪人はあっさりと倒
されてしまうのであった。

ワルザード・スルー（地球名：源雅）は、そんな現状を本気で憂いている、クァークゴ帝国遠征軍の
女幹部である。彼女は、毎週の敗北から何も学ぼうとしない司令官や、どこかズレた発明を繰り返す
天才科学者らの下で、頭の痛い日々を過ごしていた。

そんな中、次の作戦は吸血怪人ドラキュラスを日本に送りこむことに決まった。ドラキュラスは、血
を吸った人間をドラキュラスに変えてしまう恐るべき怪人である。ドラキュラスに血を吸われた人間
もまた、他の人間の血を吸って仲間のドラキュラスを増やしていく。こうして地球全土をドラキュラ
スで埋めつくしてしまおうという作戦だ。

これを聞いたワルザードは、すぐに悟った。この作戦は、幼稚園バスの乗っ取りのような普段やって
いるセコい作戦とは訳が違う。あのダメ司令官が立案したものにしては珍しく、本当に地球を征服で
きる可能性を秘めていると。

倍々ゲームの勢いは恐ろしい。地上に降りたったドラキュラスは、またたく間に仲間の数を増やして
いった。このまま行けば地球侵略は目と鼻の先だと思われた。だがその瞬間、ワルザードの脳裏を、
強烈にいやな予感が走り抜けた。まさか、この怪人、オリジナルが倒されると仲間も全滅するなんて
ことはないよな？

慌ててドラキュラスを設計開発した科学者を問いつめたところ、やはりワルザードの危惧していた通
りだった。オリジナルのドラキュラスがやられると、血を吸われた人間はすべて元に戻るように設計
してあるのだという。ふざけんなよ開発者。どうしてそんな余計な機能をつけた！

ワルザードは、開発担当者に飛び膝蹴りをきめると、すぐさまオリジナルの回収作業にとりかかっ
た。いくらオリジナルと偽物は見た目がまったく同じだといっても、このままでは、駆けつけたアー
スファイブに何かしらの理由でオリジナルを見抜かれて敗北するのが目に見えている。

開発者の話によると、ドラキュラス化した人間の重さはすべて同じだが、オリジナルのドラキュラス
はそれよりも少しだけ重いらしい。それならば、天秤ばかりを使えばオリジナルを見つけることがで
きるはずだ。アースファイブがあらわれる前に、できるだけ早くオリジナルのドラキュラスを見つけ
て回収しなければ。

Input

N

入力の１行目には、整数 N（2 ≤ N ≤ 2,000,000,000）が書かれている。これは、オリジナルと偽物を合わせたドラキュラスの数をあらわす。

Output

天秤ばかりを使ってN 体のドラキュラスの中から１体のオリジナルを見つけるには、最悪の場合で
も天秤ばかりを何回使えれば十分か。その最小値を出力せよ。ただし、天秤ばかりの左と右の皿に、
それぞれ何体かのドラキュラスを乗せて重さを比較することを、１回とカウントする。

Sample Input 1

8

Sample Output 1

2

Sample Input 2

30

Sample Output 2

4

Sample Input 3

2000000000

Sample Output 3

20



Sample input:
8


Sample output:
2

Submission status: Wrong Answer

Solution code:
N = int(input())
i = 0
while True:
    N //= 3
    i += 1
    if N == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N = int(input())
i = 0
while True:
    N //= 3
    i += 1
    if N <= 1:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N = int(input())
i = 0
if N == 3:
    print(1)
else:
    while True:
        N //= 3
        i += 1
        if N == 0:
            print(i)
            break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
#coding:utf-8

import math

if __name__ == "__main__":
    print int(math.log(int(raw_input(), 10)-1))+1;
    pass;

Submission status: Wrong Answer

Solution code:
from math import log
print int(log(int(raw_input()),3)+1)

Submission status: Wrong Answer

Solution code:
from math import log, ceil
print ceil(log(int(raw_input()),3))

Submission status: Wrong Answer

Solution code:
n = input()
from math import log
print int(log(n, 3)+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
n = 1
ans = 1

while True:
    n *= 3
    if n > N:
        print(ans)
        break
    ans+=1

Submission status: Wrong Answer

Solution code:
n = int(input())
c = 0
while n:
	n //= 3
	c += 1
print(c)

Submission status: Wrong Answer

Solution code:
import math
print int(math.log(input(),3))+1

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
while n > 1:
  ans += 1
  n = n // 3 + int(bool(n % 3))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
i = 1
while True:
    if pow(3, i) >= N:
        print(i)
        break
    i += 1

Submission status: Accepted

Solution code:
N = int(raw_input())
count = 1
while N > 3:
	count += 1
	quot, rem = divmod(N, 3)
	N = quot if rem == 0 else quot + 1
print count

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
print(math.ceil(math.log(int(input()),3)))

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        print int(math.ceil(math.log(input(), 3)))
        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Submission status: Accepted

Solution code:
from math import log, ceil
print int(ceil(log(int(raw_input()),3)))

Submission status: Accepted

Solution code:
n = input()
from math import log, ceil
print int(ceil(log(n, 3)))

Submission status: Accepted

Solution code:
#! /usr/bin/python
# -*- coding: utf-8 -*-

cnt = 0
N = int(raw_input())
while N > 1:
    if N%3 != 0:
        N = N/3+1
    else:
        N = N/3
    cnt += 1
print cnt

Submission status: Accepted

Solution code:
N=int(raw_input())
ans=0
n=1
while(n<N):
    ans+=1
    n*=3
print ans

Submission status: Accepted

Solution code:
def calc(n):
    global count
    count += 1
    if n <= 3: return
    return calc(n - (n * 2 // 3))

n = int(raw_input())


count = 0

calc(n)

print count

Submission status: Accepted

Solution code:
import math
print(math.ceil(math.log(int(input()))/math.log(3)))

Submission status: Accepted

Solution code:
import math
print(math.ceil(math.log(int(input()),3)))

Submission status: Accepted

Solution code:
from math import log
n = int(input())
print(int(log(n - 1, 3)) + 1)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        i = 0
        while n > 1:
            n = math.ceil(n/3)
            i += 1

        rr.append(i)
        break

    return '\n'.join(map(str, rr))


print(main())

Submission status: Accepted

Solution code:
N = int(input())
n = 1
ans = 1

while True:
    n *= 3
    if n>=N:
        print(ans)
        break
    ans+=1

Submission status: Accepted

Solution code:
import math
N = int(raw_input())
print int(math.ceil(math.log(N) / math.log(3)))

Submission status: Accepted

Solution code:
from math import ceil, log
print int(ceil(log(input(), 3)))

Submission status: Accepted

Solution code:
from math import ceil,log
print int(ceil(log(input(),3)))

Submission status: Accepted

Solution code:
from math import *
print int(ceil(log(input(),3)))

Submission status: Accepted

Solution code:
import math

print(math.ceil(math.log(int(input()), 3)))

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
temp = 1
while temp < N:
    temp *= 3
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
k = 1
while 3 ** k < n:
    k += 1
print(k)

Submission status: Accepted

Solution code:

N = int(input())
ans = 0

while N > 1:

    N = (N+2) // 3
    ans += 1

print (ans)

Submission status: Accepted

Solution code:
n=int(input())
import math
ans=math.ceil(math.log(n,3))
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())


N = inp()
if N <= 3:
    print(1)
else:
    ans = 1
    while True:
        N = (N+2)//3
        ans += 1
        if N<= 3:
            break
    print(ans)

Submission status: Accepted

Solution code:
x = int(input())
count = 1
val = 3
while(val < x):
    val *= 3
    count += 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
tmp = 1
while n > tmp:
    tmp *= 3
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    N = get_int()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    for i in range(100):
        if 3 ** i >= N:
            print(i)
            return
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

def getN():
    return int(input())

def getlist():
    return list(map(int, input().split()))

def solve(n):
    cnt = 0
    while(True):
        n = math.ceil(n / 3)
        cnt += 1
        if n == 1:
            return cnt

n = getN()
print(solve(n))

Submission status: Runtime Error

Solution code:
#coding:utf-8

import sys
import copy

def main():
    line = sys.stdin.readline()
    #case
    while line.split() != ["0","0"]:
        analy(line)
        line = sys.stdin.readline()
    return

def analy(line):
    #t
    field = [int(n) for n in line.split()]
    # *&
    num = int(sys.stdin.readline())
    data = []
    for i in range(num):
        a = sys.stdin.readline()
        b = [int(n) for n in a.split()]
        #*&
        data.append(b)
    print (compute(field, data))

def compute(field, ng):
    list = []
    for i in range(field[1]):
        for j in range(field[0]):
            #*?&k??WfDO
                if i == 0 :
                    #j
                    if [j+1,i+1] in ng:
                        list.append(0)
                    elif j == 0:
                        #?LjD
                        list.append(1)
                    else:
                        list.append(list[j-1])
                else:
                    if [j+1,i+1] in ng:
                        list[j] = 0
                    elif j != 0:
                    #no left >> the same.
                        list[j] = list[j-1] + list[j]
    return list[len(list)-1]

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8

import sys
import copy

def main():
    line = sys.stdin.readline()
    while line.split() != ["0","0"]:
        analy(line)
        line = sys.stdin.readline()
    return

def analy(line):
    field = [int(n) for n in line.split()]
    num = int(sys.stdin.readline())
    data = []
    for i in range(num):
        a = sys.stdin.readline()
        b = [int(n) for n in a.split()]
        data.append(b)
    print (compute(field, data))

def compute(field, ng):
    list = []
    for i in range(field[1]):
        for j in range(field[0]):
                if i == 0 :
                    if [j+1,i+1] in ng:
                        list.append(0)
                    elif j == 0:
                        #?LjD
                        list.append(1)
                    else:
                        list.append(list[j-1])
                else:
                    if [j+1,i+1] in ng:
                        list[j] = 0
                    elif j != 0:
                    #no left the same.
                        list[j] = list[j-1] + list[j]
    return list[len(list)-1]

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8

import sys
import copy

def main():
    line = sys.stdin.readline()
    while line.split() != ["0","0"]:
        analy(line)
        line = sys.stdin.readline()
    return

def analy(line):
    field = [int(n) for n in line.split()]
    num = int(sys.stdin.readline())
    data = []
    for i in range(num):
        a = sys.stdin.readline()
        b = [int(n) for n in a.split()]
        data.append(b)
    print (compute(field, data))

def compute(field, ng):
    list = []
    for i in range(field[1]):
        for j in range(field[0]):
                if i == 0 :
                    if [j+1,i+1] in ng:
                        list.append(0)
                    elif j == 0:
                        list.append(1)
                    else:
                        list.append(list[j-1])
                else:
                    if [j+1,i+1] in ng:
                        list[j] = 0
                    elif j != 0:
                    #no left the same.
                        list[j] = list[j-1] + list[j]
    return list[len(list)-1]

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8

import sys
import copy

def main():
    line = sys.stdin.readline()
    while line.split() != ["0","0"]:
        analy(line)
        line = sys.stdin.readline()
    return

def analy(line):
    field = [int(n) for n in line.split()]
    num = int(sys.stdin.readline())
    data = []
    for i in range(num):
        a = sys.stdin.readline()
        b = [int(n) for n in a.split()]
        data.append(b)
    print (compute(field, data))

def compute(field, ng):
    list = []
    for i in range(field[1]):
        for j in range(field[0]):
                if i == 0 :
                    if [j+1,i+1] in ng:
                        list.append(0)
                    elif j == 0:
                        #左がない
                        list.append(1)
                    else:
                        list.append(list[j-1])
                else:
                    if [j+1,i+1] in ng:
                        list[j] = 0
                    elif j != 0:
                    #no left the same.
                        list[j] = list[j-1] + list[j]
    return list[len(list)-1]

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
  
import sys
import copy
  
def main():
    line = sys.stdin.readline()
    #case
    while line.split() != ["0","0"]:
        analy(line)
        line = sys.stdin.readline()
    return
  
def analy(line):
    #????
    field = [int(n) for n in line.split()]
    # ???A?c
    num = int(sys.stdin.readline())
    data = []
    for i in range(num):
        a = sys.stdin.readline()
        b = [int(n) for n in a.split()]
        #???A?c
        data.append(b)
    print (compute(field, data))
  
def compute(field, ng):
    list = []
    for i in range(field[1]):
        for j in range(field[0]):
            #???¨?c???????????¢??
                if i == 0 :
                    #??????
                    if [j+1,i+1] in ng:
                        list.append(0)
                    elif j == 0:
                        #?¶?????¢
                        list.append(1)
                    else:
                        list.append(list[j-1])
                else:
                    if [j+1,i+1] in ng:
                        list[j] = 0
                    elif j != 0:
                    #no left >> the same.
                        list[j] = list[j-1] + list[j]
    return list[len(list)-1]
  
if __name__ == "__main__":
    main()