Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.Scanner; public class Memory { public static void main(String []args){ Scanner scan = new Scanner(System.in); int s = scan.nextInt(), e = scan.nextInt(); int a = e, b = e, c = e; long count = 0; while(a != s || b != s || c != s){ c=a+b-1<s?a+b-1:s; int temp = c; c = b; b = a; ...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x, y = list(map(int, input().split())) a = [y] * 3 ans = 0 while (1): if (a[0] == x and a[1] == x and a[2] == x): break a[0] = min(x, a[1] + a[2] - 1) a.sort() ans += 1 print(ans)
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> const long long mod = 1000000007; const double PI = 3.14159265358979323846; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t; t = 1; while (t--) { long long x, y; cin >> x >> y; vector<long long> a(3, y); ...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.Scanner; public class MemoryAndDeevolutionC { static int total = 0; static int x; public static void main(String[] args) { Scanner input = new Scanner(System.in); x = input.nextInt(); int y = input.nextInt(); System.out.println(recur(y, y, y)); } public static int recur(int a, int b, in...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.Scanner; import java.util.Arrays; public class df { public static void main(String args[]) { Scanner s=new Scanner(System.in); int x=s.nextInt(); int y=s.nextInt(); int a[]=new int[3]; int f=0; Arrays.fill(a,y); int t=0; while(f!=1) { if(a[0]!=x) { int w=(a[1]+a[2])-1;...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int a[3]; int x, y; cin >> x >> y; a[0] = a[1] = a[2] = y; int cnt = 0; while (a[0] != x) { a[0] = min(x, a[1] + a[2] - 1); sort(a, a + 3); cnt++; } cout << cnt << endl; return 0; }
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); long long x, y; cin >> x >> y; long long a[3] = {y, y, y}, ans = 0; do { a[0] = a[1] + a[2] - 1; a[0] = min(a[0], x); sort(a, a + 3); ans++; } while (a[0] != x or a[1] != x or a[2] ...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.*; public class r370c { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); int y2 = y; int y3 = y; int time = 0; while (y < x) { int tmp = y + y2 - 1; y3 = y2; y2 = y; ...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.*; import java.io.*; import java.lang.*; public class C712 { private static long mod = 1000000007; public static void main(String[] args) { InputReader in=new InputReader(System.in); PrintWriter pw=new PrintWriter(System.out); int n=in.nextInt(); int m=in.nextInt(); int t1=m,t2=...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; long long n, avg, sum; set<int> ap; void prepro() {} int main() { ios::sync_with_stdio(false); cin.tie(0); cout.precision(17); int x, y, ans = 0; cin >> x >> y; vector<int> a(3, y); while (a[0] < x) { a[0] = min(x, a[1] + a[2] - 1), ans++; sort(a.begin...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int solve(int x, int y) { int current[3] = {x, x, x}; int min_count = 1; int count = 1; current[0] = y; while (1) { if (current[1] != y) { current[1] = current[2] - current[0] + 1; ++count; if (current[1] < y) current[1] = y; } if (cu...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.io.IOException; import java.io.InputStream; import java.util.InputMismatchException; public class B370{ void solve() { int x = ni(); int y = ni(); int[] t = {y,y,y}; int cn = 0; for(int i=0;!allX(t,x);i++) { if(i%3==0) { int rch = t[1]+t[2]-1; t[0] = Math.min(rch,x); } el...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x, y = map(int, input().split()) cur = y, y, y cnt = 0 while cur < (x, x, x): new = cur[1] + cur[2] - 1 cur = cur[1], cur[2], new cnt += 1 print(cnt)
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x,y=map(int,raw_input().split()) a,b,c=y,y,y rep=0 while(a!=x): a,b,c=sorted([min(b+c-1,x),b,c]) rep+=1 print rep
PYTHON
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int a[3], x, y, count = 0; scanf("%d %d", &x, &y); a[0] = a[1] = a[2] = y; while (true) { sort(a, a + 3); if (a[0] == x && a[1] == x && a[2] == x) break; a[0] = a[1] + a[2] - 1; if (a[0] > x) a[0] = x; count++; } cout << count <<...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int maxn = 1e5 + 20; priority_queue<int> q; int main() { int x, y; scanf("%d%d", &x, &y); for (int i = 0; i < 3; i++) q.push(y); int ans = 0; while (1) { int z = q.top(); q.pop(); y = q.top(); q.pop(); if (z >= x) { ...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
/* Keep solving problems. */ import java.util.*; import java.io.*; public class CFA { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; final long MOD = 1000L * 1000L * 1000L + 7; int[] dx = {0, -1, 0, 1}; int[] dy = {1, 0, -1, 0}; void solve() throws IOException ...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x, y = list(map(int, input().split())) ar = [y, y, y] i = 0 while ar[0] < x or ar[1] < x or ar[2] < x: if ar[0] >= ar[1] <= ar[2]: ar[1] = ar[0] + ar[2] - 1 elif ar[0] >= ar[2] <= ar[1]: ar[2] = ar[0] + ar[1] - 1 elif ar[1] >= ar[0] <= ar[2]: ar[0] = ar[1] + ar[2] - 1 i += 1 prin...
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.*; import java.io.*; public class Equi1 { public static void main(String args[]) { InputReader in=new InputReader(System.in); int x=in.readInt(); int y=in.readInt(); int a1=y; int a2=y; int a3=y; int i,j,count=0; while(true) { if(a1>=x && a2>=x && a3>=x) { System.out.p...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
def exists(a, b, c): return a < b + c and b < a + c and c < a + b x, y = [int(i) for i in input().split()] a, b, c = y, y, y count = 0 while a != x or b != x or c != x: a, b, c = sorted([a, b, c]) a = x if exists(x, b, c) else b + c - 1 count += 1 print(count)
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper plug-in ...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; if (n == m) { puts("0"); return 0; } if (n > m) swap(n, m); int ans = 0; int num[5]; num[0] = num[1] = num[2] = n; while (1) { num[0] = min(m, num[1] + num[2] - 1); ans++; sort(num, num + 3); if...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.*; import java.io.*; public class Class{ public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int x = Integer.parseInt(st.nextToken()); ...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
s = input() x = int(s.split()[0]) y = int(s.split()[1]) a = [0] * 25 a[0] = y a[1] = 2 * y - 1 ans = 0 for i in range(2, 25): if x <= a[i - 1]: ans = i + 1 break a[i] = a[i - 1] + a[i - 2] - 1 print(ans)
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
//package geometry; import java.io.*; import java.util.*; import java.util.Map.Entry; import java.text.*; import java.math.*; import java.util.regex.*; import java.awt.Point; /** * * @author prabhat // use stringbuilder,TreeSet, priorityQueue */ public class point4{ public static long[] BIT; public stati...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long long x, y; cin >> x >> y; vector<long long> sides; for (int i = 0; i < 3; i++) { sides.push_back(y); } long long cnt = 0; while (1) { sort(sides.begin(), sides.end()); if (sides[0] == sides[2] && sides[0] == x) { break; ...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x, y = map(int, input().split()) ans = 1 sides = [y]*3 while sides[-1] < x: ans += 1 sides[2] = min(sides[0] + sides[1] - 1, x) sides = sorted(sides, reverse=True) print(ans-1)
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int x, y, a, b, c, ans; int main() { cin >> x >> y; if (x > y) swap(x, y); a = b = c = x; while (true) { a = b + c - 1; ans++; if (a >= y) break; b = a + c - 1; ans++; if (b >= y) break; c = a + b - 1; ans++; if (c >= y) break; ...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.PriorityQueue; import java.util.StringTokenizer; public class C { public static void solve(InputReader in, PrintWriter out...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int x, y; cin >> x >> y; int a = y, b = y, c = y; int ans = 0; while (c < x) { ans++; c = min(x, b + a - 1); swap(a, b); swap(b, c); } cout << ans << endl; }
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
s=input().split() tr=int(s[0]) gl=int(s[1]) list=list(range(3)) list[0]=gl list[1]=gl list[2]=gl b=0 while list[0]!=tr or list[1]!=tr or list[2]!=tr: if (list[1]+list[2]-1)>tr: if list[0]!=tr: list[0]=tr b+=1 else: if list[0]!=tr: list[0]=list[1]+list[2]-1 ...
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int a, b, c, x, y, cnt = 0, cnt2 = 0; bool triangle(int a, int b, int c) { return (a + b > c && a + c > b && b + c > a); } bool F(int mid, int x) { return (triangle(x + mid, x, x) && triangle(x + mid, x + mid, x)); } int main() { ios_base::sync_with_stdio(0); cin.ti...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x, y = map(int, input().split()) per = 0 if x !=y else 3 ans = 0 per1 = y per2 = y per3 = y while per < 3: if per1 <= per2 and per1 <= per3: if per3 + per2 - 1 >= x: per += 1 per1 = x else: per1 = per3 + per2 - 1 elif per2 <= per1 and per2 <= per3: if ...
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int x, y, s; void Calc(int a, int b, int c) { if (a == b && b == c && c == x) return; s++; Calc(b, c, min(b + c - 1, x)); } int main() { scanf("%d%d", &x, &y); Calc(y, y, y); printf("%d\n", s); return 0; }
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.Scanner; public class Codeforces370_2C { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s[] = in.nextLine().split(" "); in.close(); int first = Integer.parseInt(s[0]); int last = Integer.parseInt(s[1]); int sm = last, med = last, lar = last; int te...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int x, y; cin >> x >> y; int a[3]; a[0] = y; a[1] = y; a[2] = y; int c = 0; while (a[0] != x || a[1] != x || a[2] != x) { a[0] = min(a[1] + a[2] - 1, x); sort(a, a + 3); c++; } cout << c << endl; }
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, b, c, t, arr[3]; scanf("%d%d", &n, &m); for (int i = 0; i < 3; i++) { arr[i] = m; } int ans = 0; while (arr[0] != n || arr[1] != n || arr[2] != n) { arr[0] = arr[1] + arr[2] - 1; if (arr[0] > n) arr[0] = n; sort(arr, arr...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; long long a[10]; int main() { long long x, y, i, j, t = 0; cin >> x >> y; a[1] = a[2] = a[3] = y; while (1) { if (a[1] >= x && a[2] >= x && a[3] >= x) break; sort(a + 1, a + 1 + 3); a[1] = (a[2] + a[3]) - 1; t++; } cout << t << endl; return 0; ...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; const double PI = 2 * acos(0); const int MOD = 1000000007; const int HASH = 3137; void solve() { int a, b; scanf("%d%d%d", &a, &b); int x = b; int y = b; int z = b; int ret = 0; while (x < a || y < a || z < a) { ret++; if (ret % 3 == 1) { z = min...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
def main(): x, y = map(int, input().split()) if x > y: x, y = y, x a = b = c = x res = 0 while a < y: a, b, c = b, c, b + c - 1 res += 1 print(res) if __name__ == '__main__': main()
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x, y = map(int, input().split()) l = [y, y, y] def arg(): argmax = 0 argmin = 0 for i in range(1, 3): if l[i] > l[argmax]: argmax = i if l[i] < l[argmin]: argmin = i if argmax == argmin: argmax = 0 argmin = 1 tmp = [0, 1, 2] tmp.remove(ar...
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.*; public class MemoryTriangles { public static void main(String [] args) { Scanner sc=new Scanner(System.in); int x=sc.nextInt(); int y=sc.nextInt(); int[] a=new int[3]; for(int i=0;i<3;i++) a[i]=y; int count=0; while(a[0]!=x || a[1]!=x ||a[2]...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
""" @author: wangquaxiu @time: 2020/2/23 18:04 """ x,y = input().split() x = int(x) y = int(y) a = [y,y,y] count = 0 r = 2 while(True): a[r] = a[r-1]+a[r-2]-1 count+=1 if(min(a) >= x): break r = (r+1)%3 print(count)
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int x, y; int a[4]; bool cmp() { return a[1] == a[2] && a[2] == a[3] && a[1] == y; } int solve() { int cnt = 0; while (true) { if (cmp()) return cnt; sort(a + 1, a + 4); a[1] = a[2] + a[3] - 1; cnt++; if (a[1] > y) a[1] = y; } } int main() { scan...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
def solve(x: int, y: int) -> int: s1 = s2 = s3 = y time = 0 while s1 < x: s1 = min(s2 + s3 - 1, x) s1, s2, s3 = sorted([s1, s2, s3]) time += 1 return time x, y = list(map(int, input().split())) print(solve(x, y))
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int a, b, x[3], res; int main() { scanf("%d%d", &a, &b); x[0] = x[1] = x[2] = b; while (x[0] != a || x[1] != a || x[2] != a) { sort(x, x + 3); x[0] = min(a, x[1] + x[2] - 1); ++res; } printf("%d\n", res); }
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
//package sep102016; import java.util.*; public class C { public static void main(String... args) { Scanner s = new Scanner(System.in); final int x = s.nextInt(), y = s.nextInt(); s.close(); int a = y, b = y, c = y, n = 0; while (true) { int m = mindx(a, b, c); n++; if (m == 0) { a = b ...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int x, y; int a[4]; while (~scanf("%d%d", &x, &y)) { int temp = 0; a[0] = y, a[1] = y, a[2] = y; while (a[0] < x) { temp++; a[0] = a[1] + a[2] - 1; sort(a, a + 3); } printf("%d\n", temp); } return 0; }
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.*; /** * This program prints a single integer β€” the minimum number * of seconds required for Memory to obtain the equilateral * triangle of side length y if it starts with the equilateral * triangle of side length x. * * @author Group 5 * @version 1.00 2016/10/26 */ public class MemoryAndDeEv...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; /** * @author Aydar Gizatullin a.k.a. lightning95, aydar.gizatullin@gmail.com * Created on 11/3/16. */ public class ProbC { private RW rw; private String FILE_NAME = "file"; public static void main(String[] args) { ...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; bool isTriangle(int a, int b, int c) { if (a < b + c && b < a + c && c < a + b) return true; return false; } int main() { int a, b, c; int y, x; cin >> y >> x; a = x, b = x, c = x; int i = 0; while (true) { if (a >= y && b >= y && c >= y) { cout <<...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x, y = list(map(int, input().split())) x, y = min(x, y), max(x, y) a, b, c = x, x, x ans = 0 while (not a == b == c == y): a = min(b + c - 1, y) ans += 1 if (not a == b == c == y): b = min(a + c - 1, y) ans += 1 if (not a == b == c == y): c = min(a + b - 1, y) ...
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
def solve(n,m): a=[m,m,m];c=0 while a[-1]+a[-2]-1<n: a[0]=a[-1]+a[-2]-1;c+=1;a.sort() return c+3 n,m=map(int,input().split());print(solve(n,m))
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x=input().split() x[0], x[1]=int(x[0]), int(x[1]) y = [x[1]]*3 c = 0; while (y[2]<x[0]): y[0],y[1],y[2] = y[1],y[2],y[1]+y[2]-1 c+=1 c+=2 print(c)
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
a = input().split() s = 0 i = j = k = int(a[1]) while i <= int(a[0]): s += 1 k = j j = i i = i + k - 1 print(s + 2)
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
b,a=map(int,input().split()) t=0 s=[a,a,a] while min(s)<b: x=min(s) if s[0]==x: s[0]=min(s[1]+s[2]-1,b) elif s[1]==x: s[1]=min(s[0]+s[2]-1,b) else: s[2]=min(s[0]+s[1]-1,b) t+=1 print(t)
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.*; /** * * @author root */ public class C { static int x; static int y; public static void main(String ...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 7; int n, m; int ha[3]; int x, y; int main() { scanf("%d%d", &x, &y); int ans = 0; ha[0] = ha[1] = ha[2] = y; while (ha[0] < x) { ans++; ha[0] = min((ha[1] + ha[2] - 1), x); sort(ha, ha + 3); } printf("%d\n", ans); return 0; ...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#!/usr/bin/python3 def transform(a, b, c, y): ans = 0 while True: if a == b == c == y: return ans a, b, c = sorted([a, b, c], reverse=True) #print(a, b, c) c = min(a + b - 1, y) ans += 1 x, y = map(int, input().split()) print(transform(y, y, y, x))
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int x, y; int a, b, c; cin >> x >> y; if (x == y) { cout << 0 << endl; return 0; } int step = 0; a = b = c = y; while (c != x) { int d = min(x, b + c - 1); a = c; c = b; b = d; vector<int> nums; nums.push_back(a);...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
if __name__ == '__main__': x, y = map(int, input().split()) a, b, c = y, y, y steps = 0 while(a < x): #print(a, b, c) a, b, c = b, c, min(x, b+c-1) steps += 1 print(steps)
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.io.*; import java.util.*; import java.lang.*; import java.util.HashMap; public class templ { int binarySearch(int arr[], int l, int r, int x) { if (r >= l) { int mid = l + (r - l)/2; if (arr[mid] == x) return mid; if (arr[mid] > x) ...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
c=0 d=0 t=input().split() x=int(t[0]) y=int(t[1]) xx=[y,y,y] yy=[x,x,x] while(yy!=xx): xx.sort() z=sum(xx[1:3])-1 c=c+1 if(z>=x): xx[0]=x else: xx[0]=z print(c)
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.*; public class memory { public static void main(String args[]) { Scanner ex=new Scanner(System.in); int y=ex.nextInt(); int x=ex.nextInt(); int s1=x,s2=x,s3=x; int steps=0; while(true) { if(s1<=s2&&s1<=s3) s1=s2+s3...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.io.IOException; import java.io.PrintStream; import java.util.Arrays; import java.util.Scanner; public class C { private static Scanner in = new Scanner(System.in); private static PrintStream out = System.out; public static void main(String[] args) throws IOException { int x = in.nextInt(); int y...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; long long s, c, i, k, j, n, m, z, b; long long t, cas, d, i1, a, i2, r, w; long long ta[10]; vector<pair<int, int> > vk, vk2; string wy; vector<long long> vz; int main() { cin >> a >> b; z = 0; vz.clear(); vz.push_back(b); vz.push_back(b); vz.push_back(b); whi...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; bool f(vector<int> &v, int x) { sort(v.begin(), v.end()); if (v.front() == x && v.back() == x) return true; if (x < v[1] + v[2]) { v[0] = x; return false; } else { v[0] = v[1] + v[2] - 1; return false; } } int main() { int x, y; cin >> x >> y; ...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
from __future__ import division from math import ceil from collections import Counter x, y = raw_input("").split(" ") x, y = int(x), int(y) y = [y, y, y] count = 0 while not (y[0] == y[1] == y[2] == x): y.sort() y[0] = min(y[1] + y[2] - 1, x) count += 1 print count
PYTHON
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
# ========= /\ /| |====/| # | / \ | | / | # | /____\ | | / | # | / \ | | / | # ========= / \ ===== |/====| # code if __name__ == "__main__": n,m = map(int,input().split()) a = [m,m,m] ans = 0 while a != [n,n...
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; const double PI = 3.141592653589793238; long long powmod(long long a, long long b) { long long res = 1; a %= 1000000007; for (; b; b >>= 1) { if (b & 1) res = res * a % 1000000007; a = a * a % 1000000007; } return res; } bool check(int arr[], int n) { if...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int n, k, a, b, c, ans; int main() { int i, t; scanf("%d%d", &n, &k), a = b = c = k; while (1) { if (a > b) swap(a, b); if (a > c) swap(a, c); t = max(a + b, b + c), t = max(t, a + c); if (t > n) break; a = b + c - 1, ans++; } return printf("%d...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; int x[3]; while (~scanf("%d%d", &a, &b)) { x[0] = x[1] = x[2] = b; c = 0; while (x[0] <= a || x[1] <= a || x[2] <= a) { sort(x, x + 3); x[0] = x[1] + x[2] - 1; c++; } printf("%d\n", c); } }
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int x, y, a, b, c, a1, b1, c1, Move; int main() { cin >> x >> y; a = b = c = y; while (a != x || b != x || c != x) { if (a > b) swap(a, b); if (a > c) swap(a, c); if (b > c) swap(b, c); a = min(x, b + c - 1); Move++; } cout << Move << endl; }
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long int x, y; cin >> x >> y; long int a[3]; a[0] = a[1] = a[2] = y; long int turns = 0; while (a[0] != x || a[1] != x || a[2] != x) { sort(a, a + 3); a[0] = a[1] + a[2] - 1; if (a[0] > x) { a[0] = x; } turns++; } cout ...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n; int y; cin >> n >> y; int a = y; int b = y; int c = y; long long ans1 = 0; while (1) { a = b + c - 1; ans1++; if (a > n) { a = n; } if (a == n && b == n && c == n) { break; } b = a + c - 1; ans1...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x, y = (int(x) for x in raw_input().split()) t = [y, y, y] c = 0 while True: if t[0] == x and t[2] == x: break t = sorted([t[1], t[2], min(x, t[1] + t[2] - 1)]) c += 1 print c
PYTHON
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int x, y; scanf("%d %d", &x, &y); int count = 0, a[] = {y, y, y}; while ((a[1] + a[2]) <= x) { a[0] = a[1] + a[2] - 1; sort(a, a + 3); count++; } if (a[0] != x) count++; if (a[1] != x) count++; if (a[2] != x) count++; cout << count...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
# your code goes here x,y=map(int,raw_input().strip().split()) lii=[y,y,y] count=0 while lii!=[x,x,x]: #print lii tem=min(lii) ind=lii.index(tem) lii[ind]=min((sum(lii)-tem-1),x) count+=1 print count
PYTHON
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int x, y; cin >> y >> x; int a[3]; for (int i = 0; i < 3; i++) { a[i] = x; } int u = 0; while (a[0] != y) { a[0] = min(a[2] + a[1] - 1, y); sort(a, a + 3); u++; } cout << u; }
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
/** * @author Kunal * */ import java.io.PrintWriter; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.IOException; import java.util.StringTokenizer; public class C370 { public static void main(String[] args) { InputReader in = new InputReader(); PrintWriter out = new PrintWrite...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; long long a[1000]; int main() { long long n, m, t = 0; scanf("%lld%lld", &n, &m); a[1] = m; a[2] = m; a[3] = m; while (1) { t++; long long k = min(a[1], min(a[2], a[3])); if (k == a[1]) { if (a[2] + a[3] - 1 <= n) { a[1] = a[2] + a[3] -...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector<int> a = {m, m, m}; int ans = 0; while (true) { sort(a.begin(), a.end()); if (a[0] == n && a[2] == n) break; int t1 = a[1] + a[2] - 1; if (t1 > n) { t1 = n; } ...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.*; public class A { public static void main(String ar[]) { Scanner s=new Scanner(System.in); int y=s.nextInt(); int x=s.nextInt(); int t=0; int a=x,b=x,c=x; while(a<y || b<y || c<y) { if(a<=b && a<=c) ...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.lang.*; import java.util.*; import java.io.*; public class ProblemB{ public void run(){ Scanner in = new Scanner(System.in); int old_tri = in.nextInt(); int new_tri = in.nextInt(); int[] arr = {new_tri , new_tri, new_tri}; int i = 0; while(arr[0] != old_tri || arr[1] != old_tri || arr[2] != ...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#! /usr/bin/env python3 x, y = (int(i) for i in input().split()) a, b, c = y, y, y ans = 0 while a < x: a, b, c = sorted((min(x, b + c - 1), b, c)) ans += 1 print(ans)
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
def devolution(a, b): lst, result = [b] * 3, 0 while lst != [a] * 3: lst.sort() lst[0] = min(lst[1] + lst[2] - 1, a) result += 1 return result x, y = [int(i) for i in input().split()] print(devolution(x, y))
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.util.*; import java.io.*; public class Main { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pw = new PrintWriter(System.out); public static void main(String[] args) throws Exception { String[] parts=br.readLine().split(" "); ...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int x, y; cin >> x >> y; int all = 0; long long int counter = 0; int t[3] = {y, y, y}; while (all != 3) { if (t[0] + t[1] - 1 < x) { t[2] = t[0] + t[1] - 1; counter++; } else if (t[2] != x) { t[2] = x; counter++; ...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x, y = map(int, raw_input().split()) sides = [y, y, y] ops = 0 while True: if sides[0] == x: break sides[0] = min(x, sides[1] + sides[2] - 1) sides.sort() ops += 1 print ops
PYTHON
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T> inline ostream &operator<<(ostream &out, const vector<T> &v) { for (auto &it : v) out << it << ' '; return out; } template <typename T> inline istream &operator>>(istream &in, vector<T> &v) { for (auto &it : v) in >> it; return in; } template <...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; void scanint(int &x) { register int c = getchar(); x = 0; int neg = 0; for (; ((c < 48 || c > 57) && c != '-'); c = getchar()) ; if (c == '-') { neg = 1; c = getchar(); } for (; c > 47 && c < 58; c = getchar()) { x = (x << 1) + (x << 3) + c - 4...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
def read(t=None): string = raw_input() return string if t is None else [t(x) for x in string.split()] def solve(): tar, ini = read(int) a = [ini for i in range(3)] n = 0 while a[0] < tar: a[0] = min(a[1]+a[2]-1, tar) n += 1 #print "n: %2d: %s"%(n, a) a = sorted(a) print n if __name__ == "__main__": s...
PYTHON
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; long long int s[4]; int main() { long long int x, y; while (scanf("%I64d%I64d", &x, &y) == 2) { s[0] = y; s[1] = y; s[2] = y; sort(s, s + 3); long long int cnt = 0; while (1) { if (s[0] == x && s[1] == x && s[2] == x) { break; ...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x,y=map(int,raw_input().split()) a=[y]*3 count=0 while x!=a[0] or x!=a[1] or x!=a[2]: a[0]=min(x,a[1]+a[2]-1) a.sort() count+=1 print count
PYTHON
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int x, y; cin >> x >> y; int a = y, b = y, c = y; int cnt = 0; while (a < x || b < x || c < x) { if (cnt % 3 == 0) a = b + c - 1; if (cnt % 3 == 1) b = a + c - 1; if (cnt % 3 == 2) c = b + a - 1; cnt++; } cout << cnt; return 0; }...
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
x,y=input().split() x=int(x) y=int(y) a=y b=y c=y z=1 ans=0 while True: if z==1: a=b+c-1 z+=1 ans+=1 if a>=x: break elif z==2: b=c+a-1 z+=1 ans+=1 if b>=x: break else: c=a+b-1 z=1 ans+=1 i...
PYTHON3
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int x, y; scanf("%d%d", &x, &y); int A[] = {y, y, y}, ans = 0; while (A[0] != x) { A[0] = min(x, A[1] + A[2] - 1); sort(A, A + 3); ans++; } cout << ans << endl; }
CPP
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Iterator; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Writer; imp...
JAVA
712_C. Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int a[5], x, y; scanf("%d%d", &y, &x); for (int i = 1; i <= 3; i++) a[i] = x; int cnt = 0; while (1) { sort(a + 1, a + 4); int s1 = a[3] - a[2] + 1, s2 = a[2] + a[3] - 1; if (a[1] == y && a[3] == y) break; a[1] = min(s2, y); cnt++;...
CPP