712C - Memory and De-Evolution - CodeForces Solution


greedy math *1600

Please click on ads to support us..

Python Code:

import math
 
alfabet = {'a': 1, 'b': 2,'c': 3,'d': 4,'e': 5,'f': 6,'g': 7,'h': 8,'i': 9,'j': 10,'k': 11,'l': 12,'m': 13,'n': 14,'o': 15,'p': 16,'q': 17,'r': 18,'s': 19,'t': 20,'u': 21,'v': 22,'w': 23,'x': 24,'y': 25,'z': 26}
alfabet_2={'1':"a", '2':"b", '3':"c", '4':"d", '5':"e", '6':"f", '7':"g", '8':"h", '9':"i", '10':"j", '11':"k", '12':"l", '13':"m", '14':"n", '15':"o", '16':"p", '17':"q", '18':"r", '19':"s", '20':"t", '21':"u", '22':"v", '23':"w", '24':"x", '25':"y", '26':"z"}
 
 
def transformare_baza(numar,baza):
 
 transformare=""
 while numar>=baza:
  rest=numar%baza
  numar=numar//baza
  transformare+=str(rest)
 
 transformare+=str(numar)
 noua_baza=transformare[::-1]
 return noua_baza
 
 
def functie_string_baza(stringul,baza):
 answ=0
 stringul=stringul.lower()
 lungime=len(stringul)
 for j in range(lungime):
  if stringul[j] in alfabet:
   answ+=(baza**(lungime-1-j))*(alfabet[stringul[j]]+9)
  else:
      answ+=(baza**(lungime-1-j))*(int(stringul[j]))
  
 return (answ)
 
from decimal import *
 
for contorr in range(1):
 
 x,y=list(map(int, input().split()))
 
 if y==x:
  print(0)
 else:
  
  minimul=min(x,y)
  maximul=max(x,y)
  cate=0
  
  lista=[0]*3
  lista[0]=minimul
  lista[1]=minimul
  lista[2]=minimul
  
  while lista[0]!=maximul or lista[1]!=maximul or lista[2]!=maximul:
   lista.sort()
   lista[0]=min(maximul,lista[1]+lista[2]-1)
   cate+=1
  print(cate)  
  
   
    
    
   
 


Comments

Submit
0 Comments
More Questions

1370C - Number Game
1206B - Make Product Equal One
131A - cAPS lOCK
1635A - Min Or Sum
474A - Keyboard
1343A - Candies
1343C - Alternating Subsequence
1325A - EhAb AnD gCd
746A - Compote
318A - Even Odds
550B - Preparing Olympiad
939B - Hamster Farm
732A - Buy a Shovel
1220C - Substring Game in the Lesson
452A - Eevee
1647B - Madoka and the Elegant Gift
1408A - Circle Coloring
766B - Mahmoud and a Triangle
1618C - Paint the Array
469A - I Wanna Be the Guy
1294A - Collecting Coins
1227A - Math Problem
349A - Cinema Line
47A - Triangular numbers
1516B - AGAGA XOOORRR
1515A - Phoenix and Gold
1515B - Phoenix and Puzzle
155A - I_love_username
49A - Sleuth
1541A - Pretty Permutations