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 |
|---|---|---|---|---|---|
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;
const long long mod = 1000000007;
const double eps = 1e-9;
const double PI = acos(-1);
template <typename T>
inline void read(T &a) {
char c = getchar();
T x = 0, f = 1;
while (!isdigit(c)) {
... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int mem[50010][3];
string str;
int N;
int valid(int i, int p) {
int &val = mem[i][p];
if (val >= 0) return val;
if (i >= N) return 1;
if (i == N - 1) return 0;
string pr = str.substr(i - p, p);
string cur = str.substr(i, 2);
val = 0;
if (pr != cur && valid(i... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int NMAX = 10005;
int n, dp[2][NMAX];
char s[NMAX];
set<string> S;
string Str(int x, int y) {
string aux = "";
for (int i = x; i <= y; i++) aux += s[i];
return aux;
}
int main() {
int i, j, l;
cin.sync_with_stdio(false);
cin >> (s + 1);
n = strlen(s + 1)... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 100;
const long double eps = 1e-11;
const long double pi = acos(-1.0L);
int myrand() { return rand(); }
unsigned rdtsc() {
unsigned ans;
asm("rdtsc" : "=a"(ans));
return ans;
}
int rnd(int x) { return myrand() % x; }
void precalc() {}
const ... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
string s;
set<string> ans;
int dp[4][maxn];
int main() {
cin >> s;
ans.clear();
int len = s.length();
if (len >= 7) ans.insert(s.substr(len - 2, 2));
if (len >= 8) ans.insert(s.substr(len - 3, 3));
reverse(s.begin(), s.end());
memset... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | '''ACCEPTED'''
import sys
pow2 = pow # for modular expo pow2(base, n, mod)
from math import *
from time import time
from collections import defaultdict
from bisect import bisect_right, bisect_left
from string import ascii_lowercase as lcs
from string import ascii_uppercase as ucs
from fractions import Fra... | PYTHON |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int DP[10005][2];
int main() {
string a;
cin >> a;
set<string> Ans;
DP[a.length() - 2][0] = 1;
DP[a.length() - 2][1] = 0;
DP[a.length() - 3][0] = 0;
DP[a.length() - 3][1] = 1;
if (a.length() >= 7) Ans.insert(a.substr(a.length() - 2, 2));
if (a.length() >= ... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int mn = INT_MIN;
const int mx = INT_MAX;
const int mod = 1000000007;
bool dp[10004];
set<string> st;
int main() {
ios::sync_with_stdio(0);
cin.tie(NULL);
memset(dp, 0, sizeof(dp));
string s;
cin >> s;
reverse(s.begin(), s.end());
dp[1] = 1;
dp[2] = 1;... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
set<string> ans;
vector<bool> dp2(s.length() + 10, false), dp3(s.length() + 10, false);
dp2[s.length()] = dp3[s.length()] = true;
for (int n = s.length() - 2; n >= 5; n--) {
if (dp2[n] = (dp3[n + 2] ||
(dp2[... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int dp[10010][4];
string s;
set<string> v;
int dfs(int x, int d) {
if (x == s.size()) {
return 1;
}
if (dp[x][d] != -1) return dp[x][d];
int ans = 0;
for (int i = 2; i <= 3; i++) {
if (x + i > s.size()) continue;
if (i == d and s.substr(x - d, d) == s.... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int l = s.size();
bool app[l + 2][2];
for (int i = 0; i < l + 2; i++) {
app[i][0] = false;
app[i][1] = false;
}
app[l - 1][0] = false;
app[l - 1][1] = false;
app[l - 2][0] = true;
app[l - 2][1] = false;
app[l - ... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
int N, f[10001], g[10001], h[10001];
char a[10002];
int main() {
scanf("%s", a + 1);
while (a[N + 1]) N++;
f[N] = 1;
for (int i = N; i >= 7; i--) {
if (f[i]) {
g[i - 2] = 1;
h[i - 3] = 1;
}
if (g[i]) {
if (a[i - 1] != a[i + 1] || a[i] != a[i + 2]) g[i - 2] ... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | s = input()
s = s[5:]
if len(s) < 2:
print(0)
elif len(s) == 2:
print(1)
print(s)
elif len(s) == 3:
print(2)
for suff in sorted([s, s[-2:]]):
print(suff)
else:
D = [[False for _ in range(2)] for _ in range(len(s))]
suffixes = { s[-2:], s[-3:] }
D[-2][0] = True
D[-3][1] = T... | PYTHON3 |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void Read(T &x) {
int f = 1;
char t = getchar();
while (t < '0' || t > '9') {
if (t == '-') f = -1;
t = getchar();
}
x = 0;
while (t >= '0' && t <= '9') {
x = x * 10 + t - '0';
t = getchar();
}
x *= f;
}
template ... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class Main {
FastScanner in;
PrintWriter out;
static final String FILE = "";
String s;
TreeSet<String> set = new TreeSet<>();
boolean used[][];
void work(int v, int len) {
if (v < 5)
return... | JAVA |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long int max(long long int a, long long int b) {
if (a > b)
return a;
else
return b;
}
long long int min(long long int a, long long int b) {
if (a < b)
return a;
else
return b;
}
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
ios_base::sync_with_stdio(false);
cin >> s;
int k, l, i, j;
l = s.length();
set<string> my;
int dp[l + 1];
dp[l - 2] = 1;
dp[l - 3] = 2;
if (l <= 6) {
cout << 0;
return 0;
}
if (l == 7) {
cout << 1 << endl;
cout... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 |
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.lang.*;
public class P666A{
static long mod=1000000007;
public static void main(String[] args) throws Exception{
InputReader in = new InputReader(System.in);
Print... | JAVA |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 6;
char str[maxn];
int dp[maxn][2];
int n;
vector<string> ans;
int main() {
scanf("%s", str);
n = strlen(str);
reverse(str, str + n);
for (int i = 1; i < n - 5; i++) {
if (i == 1) {
string s1 = "";
s1 += str[i];
s1 += str... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, l;
set<string> ans;
string s;
map<pair<int, string>, int> mp;
bool solve(int idx, string tmp = "") {
if (idx >= s.size()) {
return 1;
}
if (mp.count({idx, tmp})) {
return mp[{idx, tmp}];
}
string s3, s2;
bool x3, x2;
x3 = x2 = 0;
if (idx + 2 <... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;
/**... | JAVA |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | def get_suffixes(string):
if len(string) < 7:
return []
suffix_string = string[5:][::-1]
result = set()
result.add(suffix_string[:2])
dp2 = [1, 0, 1] + [0] * (len(suffix_string) -2)
dp3 = [1] + [0] * len(suffix_string)
for n in xrange(3, len(suffix_string) + 1):
if dp3[n-... | PYTHON |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 10005, inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
const long double pi = acos(-1.0L);
string a[maxn * 2];
string s;
bool dp[maxn][2];
int main() {
cin >> s;
int i, len = s.length(), m = 0;
memset(dp, 0, sizeof(dp));
for (i = len -... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
string s, s1;
set<string> se;
bool mark[20000][2];
bool cmp(int i, int j) {
if (j >= s.size()) return true;
if (s[i] != s[j]) return true;
return false;
}
int main() {
ios_base::sync_with_stdio(false);
cin >> s;
mark[s.size()][2] = true;
mark[s.size()][3] = tr... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 2e18;
const int N = 11234;
int n, m;
set<string> st;
char s[N];
int dp[N][4];
void dfs(int pos, string pre, int len) {
if (pos - 1 < 5) return;
if (dp[pos][len]) return;
dp[pos][len] = 1;
string str = "";
for (int ... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
char str[10024];
bool vis[10024][4];
set<string> ans;
set<string>::iterator it;
int main() {
int len, sum = 0;
scanf("%s", str);
len = strlen(str);
memset(vis, true, sizeof(vis));
vis[len][0] = false;
for (int i = len; i >= 5; i--) {
for (int j = 0; j < 4; j... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | import sys
input = sys.stdin.readline
s = input().strip()
n = len(s)
poss = [[False] * 2 for _ in range(n)]
poss[n - 2][0] = poss[n - 3][1] = True
for i in range(n - 4, -1, -1):
poss[i][0] = s[i: i + 2] != s[i + 2: i + 4] and poss[i + 2][0] or poss[i + 2][1]
poss[i][1] = s[i: i + 3] != s[i + 3: i + 6] and pos... | PYTHON3 |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | import java.util.HashSet;
import java.util.ArrayList;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collections;
import java.io.IOException;
import java.util.Set;
import java.u... | JAVA |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
bool mark[10005][5];
set<string> st;
char s[10005];
void go(int len, int bf) {
if (mark[len][bf]) return;
if (len <= 6) return;
mark[len][bf] = true;
bool fl = false;
if (bf == 2) {
fl |= (s[len - 1] != s[len + 1]);
fl |= (s[len - 2] != s[len]);
}
if (... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
const int N = 1e4 + 5;
const long long int mod = 1e9 + 7;
const long long int Mod = 998244353;
const long double Pi = acos(-1);
const long long int Inf = 4e18;
using namespace std;
string s;
set<string> v;
bool dp[N][4];
voi... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
ifstream fin("alfa.in");
ofstream fout("alfa.out");
string s;
bool dp[10001][4];
string rasp[20001];
int main() {
int i, n, k = 0, rs = 0;
cin >> s;
n = s.size();
s = s + "000";
if (n >= 7) {
dp[n - 2][2] = 1;
rasp[++k] = s[n - 2];
rasp[k] += s[n - 1];... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
inline bool Min(T &a, T b) {
return a > b ? (a = b, true) : false;
}
template <class T>
inline bool Max(T &a, T b) {
return a < b ? (a = b, tru... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using ii = pair<ll, ll>;
constexpr bool LOG = true;
void Log() {
if (LOG) cerr << "\n";
}
template <class T, class... S>
v... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const long double pi = acos(-1);
string s;
int dp2[10010];
int dp3[10010];
int main() {
ios_base::sync_with_stdio(0);
cout.precision(15);
cout << fixed;
cout.tie(0);
cin.tie(0);
cin >> s;
int N = int((... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
const int32_t LETT = 26;
const size_t MAX_STR = 20000;
char str[MAX_STR];
int32_t strLen;
bool occur2[LETT * LETT];
bool occur3[LETT * LETT * LETT];
bool pos2[MAX_STR];
bool pos3[MAX_STR];
int main() {
scanf("%s", str);
strLen = strlen(str);
int32_t code = str[strLen - 1] - 'a' + (str[str... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
vector<vector<int> > dp;
set<string> S;
string s;
vector<vector<string> > Substr;
vector<int> Len;
int solve(int index, int mode) {
if (dp[index][mode] != -1) return dp[index][mode];
if (index + 1 <= 4) return dp[index][mode] = 0;
if (Substr[index - 1][2] != Substr[in... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long int dp2[10004] = {0}, dp3[10004] = {0};
set<string> ans;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string s, s1, s2;
cin >> s;
long long int n = s.length();
if (n < 7) {
cout << 0 << endl;
return 0;
}
dp2[... | CPP |
666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 2 | 7 | # Reberland Linguistics
import sys
word = input()
suffixes = set()
possible = {(len(word), 2)}
my_set = set()
while possible:
d, x = possible.pop()
a = d + x
for i in [x, 5 - x]:
l = d - i
q = (l, i)
# if q in my_set or (l < 5) or (word[l:d] == word[d:a]):
# break
... | PYTHON3 |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e100;
struct Point {
double x, y;
Point() {}
Point(double x, double y) : x(x), y(y) {}
double abs() const { return hypot(x, y); }
double arg() const { return atan2(y, x); }
Point operator*(double o) const { return Poi... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct point {
double x, y;
};
double dist(point P, point Q) {
double dx = P.x - Q.x, dy = P.y - Q.y;
return sqrt(dx * dx + dy * dy);
}
vector<point> cccross(point O1, double r1, point O2, double r2) {
double d = dist(O1, O2);
double t = (d * d + r1 * r1 - r2 * r2... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, m, k;
bool debug = false;
struct Point {
double x, y;
Point() {}
Point(double x, double y) : x(x), y(y) {}
double abs() const { return hypot(x, y); }
double arg() const { return atan2(y, x); }
Point operator*(double o) const { return Point(x * o, y * o); ... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct point {
double x, y;
};
double dist(point P, point Q) {
double dx = P.x - Q.x, dy = P.y - Q.y;
return sqrt(dx * dx + dy * dy);
}
vector<point> cccross(point O1, double r1, point O2, double r2) {
double d = dist(O1, O2);
double t = (d * d + r1 * r1 - r2 * r2... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double e[4][3], x[10], y[10], tx[4][3], ty[4][3];
bool used[4];
int ans;
int sgn(double a) { return a < -1e-8 ? -1 : a > 1e-8 ? 1 : 0; }
vector<pair<double, double>> solve(double x1, double y1, double x2, double y2,
double l, double l1, do... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct point {
double x, y;
};
double dist(point P, point Q) {
double dx = P.x - Q.x, dy = P.y - Q.y;
return sqrt(dx * dx + dy * dy);
}
vector<point> cccross(point O1, double r1, point O2, double r2) {
double d = dist(O1, O2);
double t = (d * d + r1 * r1 - r2 * r2... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
struct Point {
double x, y;
Point(double _x = 0, double _y = 0) {
x = _x;
y = _y;
}
};
int result;
Point p[4][3], e[4][3], pts[12];
double dst[12][12];
int permutation[4];
void rotate(Point &p, double d) {
double cosd = cos(d);
dou... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
complex<double> leer() {
double x, y;
cin >> x >> y;
return complex<double>(x, y);
}
void leer(double input[3]) {
complex<double> in[3];
for (int i = 0; i < 3; i++) in[i] = leer();
for (int i = 0; i < 3; i++) {
int nexti = (i + 1) % 3;
input[i] = abs(in[... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e100;
struct Point {
double x, y;
Point() {}
Point(double x, double y) : x(x), y(y) {}
double abs() const { return hypot(x, y); }
double arg() const { return atan2(y, x); }
Point operator*(double o) const { return Poi... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
struct P {
double x, y;
P() {}
P(double _x, double _y) : x(_x), y(_y) {}
double abs() { return sqrt(x * x + y * y); }
P operator+(const P& a) const { return P(x + a.x, y + a.y); }
P operator-(const P& a) const { return P(x - a.x, y - a.y... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct point {
double x, y;
};
double dist(point P, point Q) {
double dx = P.x - Q.x, dy = P.y - Q.y;
return sqrt(dx * dx + dy * dy);
}
vector<point> crossing(point O1, double r1, point O2, double r2) {
double d = dist(O1, O2);
double t = (d * d + r1 * r1 - r2 * r... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
struct P {
double x, y;
P() {}
P(double _x, double _y) : x(_x), y(_y) {}
double abs() { return sqrt(x * x + y * y); }
P operator+(const P& a) const { return P(x + a.x, y + a.y); }
P operator-(const P& a) const { return P(x - a.x, y - a.y... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct point {
double x, y;
};
double dist(point P, point Q) {
double dx = P.x - Q.x, dy = P.y - Q.y;
return sqrt(dx * dx + dy * dy);
}
vector<point> crossing(point O1, double r1, point O2, double r2) {
double d = dist(O1, O2);
double t = (d * d + r1 * r1 - r2 * r... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
struct P {
double x, y;
P() {}
P(double _x, double _y) : x(_x), y(_y) {}
double abs() { return sqrt(x * x + y * y); }
P operator+(const P& a) const { return P(x + a.x, y + a.y); }
P operator-(const P& a) const { return P(x - a.x, y - a.y... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
complex<double> leer() {
double x, y;
cin >> x >> y;
return complex<double>(x, y);
}
void leer(double input[3]) {
complex<double> in[3];
for (int i = 0; i < 3; i++) in[i] = leer();
for (int i = 0; i < 3; i++) {
int nexti = (i + 1) % 3;
input[i] = abs(in[... | CPP |
68_E. Contact | Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made of 3 special columns located at some points of a Cartesian plane such that these 3 points form a triangle equal t... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e100;
struct Point {
double x, y;
Point() {}
Point(double x, double y) : x(x), y(y) {}
double abs() const { return hypot(x, y); }
double arg() const { return atan2(y, x); }
Point operator*(double o) const { return Poi... | 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 minim(int a, int b, int c) {
if (a <= b and a <= c)
return 1;
else if (b <= a and b <= c)
return 2;
else if (c <= a and c <= b)
return 3;
else
return 0;
}
int main() {
int x, y;
cin >> x >> y;
int side1, side2, side3;
side1 = side2 = side... | 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 e[3];
int main() {
int x, y;
while (~scanf("%d%d", &x, &y)) {
int ans = 0;
e[1] = e[2] = e[0] = y;
while (1) {
int t = 0;
for (int i = 0; i < 3; i++) {
if (e[t] > e[i]) t = i;
}
e[t] = e[(t + 1) % 3] + e[(t + 2) % 3] - 1 >... | 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())
a, b, c = y, y, y
cnt = 0
while True:
if a >= x and b >= x and c >= x:
break
cnt += 1
if cnt % 3 == 0:
a = b+c - 1
elif cnt % 3 == 1:
b = c + a - 1
elif cnt % 3 == 2:
c = b+a - 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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class C {
private static final boolean TEST_CASES = false;
private static class Solver {
void solve(int testCaseNo) {
int x = IO.nextInt();
int y = I... | 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 cnt = 0;
int a = y, b = y, c = y;
while (a < x || b < x || c < x) {
if (a <= b && a <= c) {
a = b + c - 1;
cnt++;
continue;
} else if (b <= a && b <= c) {
b = a + c - 1;
cnt++;
continue;
} e... | 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;
template <typename tn>
inline tn next(void) {
tn k;
cin >> k;
return k;
}
template <typename tn>
inline ostream& operator<<(ostream& os, const vector<tn>& v) {
for (unsigned i = 0; i < v.size(); i++) os << v[i] << ' ';
return os;
}
int tri[3];
int main(void) {
i... | 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 v(int &a, int &b, int &c) {
int d;
if (c < a) {
swap(a, c);
}
if (c < b) {
swap(b, c);
}
if (a > b) {
swap(a, b);
}
}
string s;
int main() {
int x, y, a[3], ans = 0;
cin >> x >> y;
a[0] = a[1] = a[2] = y;
while (a[0] != x || a[1] != 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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class C_MemoryAndDeEvolution_ED {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String[] input = bf.... | 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;
/**
* @author shayan.hati
* @since 11/09/16.
*/
public class MemoryDevolution {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int x = scn.nextInt();
int y = scn.nextInt();
int prev = y;
int newVal = 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;
int main() {
int x, y;
cin >> x >> y;
int besta = y, bestb = y, bestc = y;
int turns = 0;
while (true) {
if (besta >= x && bestb >= x && bestc >= x) {
cout << turns << endl;
break;
}
turns++;
if (turns % 3 == 1) besta = bestb + bestc - ... | 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/env python3.5
import sys
def read_data():
return map(int, next(sys.stdin).split())
def solve(f, t):
if f > t:
f, t = t, f
if f == t:
return 0
a, b, c = f, f, f
count = 0
while a < t:
c = min(a + b - 1, t)
c, b, a = sorted((a, b, c))
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.util.Scanner;
public class Main {
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, a = map(int, input().split())
b = c = a
res = 0
while a < x:
a, b, c = b, c, b + c - 1
res += 1
print(res)
# Made By Mostafa_Khaled | 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() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int x, y, ans = 0;
cin >> x >> y;
int a[3] = {y, y, y};
while (a[0] != x || a[1] != x || a[2] != x) {
sort(a, a + 3);
int sum = a[1] + a[2];
if (sum - 1 > x)
a[0] = 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 | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
void solve() {
int x, y, ans = 0;
cin >> x >> y;
int y1 = y, y2 = y, y3 = y;
int x1 = x, x2 = x, x3 = x;
while (y1 != x1 && y2 != x2 && y3 != x3) {
if (ans % 3 == 0) {
if (y2 + y3 - 1 >= x)
y1 = x;
else
... | 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 MemoryAndDeEvolution {
public static InputReader in;
public static PrintWriter out;
public static final int MOD = (int) (1e9 + 7);
public static void main(String[] args) {
in = new InputReader(System.in);
out = new PrintWriter(System.o... | 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=[int(x) for x in input().split()]
a=[y,y,y]
c=0
while(True):
a.sort()
if(a[2]+a[1]>x):
break
a[0]=a[1]+a[2]-1
c+=1
print(c+3) | 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, b = input().split()
x = int(a)
y = int(b)
x_v = [y, y, y]
result = 0
while (x_v[0] != x) or (x != x_v[1] ) or (x != x_v[2]):
x_v.sort()
x_v[0] = min(x, x_v[1] + x_v[2] - 1)
result += 1
print(result)
| 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.*;
import java.math.*;
public class Main
{
static class Reader
{
private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
public int read() {if (nu... | 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 sys
y, x = map(int, raw_input().split())
current = [ x, x, x ]
goal = [ y, y, y ]
steps = 0
while current != goal:
best_index, best_value = -1, -1
for i, a in enumerate(current):
b, c = current[(i + 1) % 3], current[(i + 2) % 3]
x = min(y, b + c - 1)
if x > a and x > best_value:
... | 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 | import math
x, y = map(int, input().split())
res = 0
now = [y, y, y]
while min(now) < x:
res += 1
ind = now.index(min(now))
o1, o2 = (ind + 1) % 3, (ind + 2) % 3
now[ind] = now[o1] + now[o2] - 1
print(res)
| 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 sol
{
/********* SOLUTION STARTS HERE ************/
private static void solve(FastScanner s1, PrintWriter out){
int x = s1.nextInt();
int y = s1.nextInt();
int a[] = new int[3];
for (int i=0;i<3;++i){
a[i] =... | 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, a[3], d = 0;
cin >> x >> y;
a[0] = a[1] = a[2] = y;
while (a[0] != x) {
a[0] = min(a[2] + a[1] - 1, x);
sort(a, a + 3);
d++;
}
cout << d;
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.io.*;
import java.util.*;
public class Main {
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int x=in.nextInt();
int y=in.nextInt();
int[] a = new int[] {y,y,y};
int recent=0;
int count=0;
while(a[recent]<x){
count++;
if(recent==0){
a[0]=a[1]+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 | import java.io.*;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.Map.Entry;
public class Palindrome {
static double eps=(double)1e-6;
static long mod=(int)1e9+7;
public static void main(String args[]){
InputReader in = ne... | 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().split()
a=int(s[0])
b=int(s[1])
count=0
g=0
C=list(range(3))
C[0]=b
C[1]=b
C[2]=b
while C[0]!=a or C[1]!=a or C[2]!=a:
if C[1]+C[2]>a:
C[0]=a
count+=1
g=C[2]
C[2]=C[1]
C[1]=C[0]
C[0]=g
else:
C[0]=C[1]+C[2]-1
count+=1
g=C[2]
C[2]=C[1]
C[1]=C[0]
C[0]=g
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, ans = 0;
cin >> y >> x;
vector<int> xa = {x, x, x};
vector<int> ya = {y, y, y};
while (xa != ya) {
sort(xa.begin(), xa.end());
int temp = xa[1] + xa[2] - 1;
if (temp > y)
xa[0] = y;
else
xa[0] = temp;
ans++;
... | 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.*;
import java.util.*;
public class C370 {
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
int x,y,a,b,c,ans,t,t2,i;
x = sc.nextInt(); y = sc.nextInt();
ans =... | 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 T = 3;
const long long MAX = 1000000001;
long long n, m, k;
int N[T];
int A[T];
int x, y;
void foo() { N[0] = min(x, N[1] + N[2] - 1); }
int main() {
cin >> x >> y;
N[0] = N[1] = N[2] = y;
int ans = 0;
while (N[0] != x || N[1] != x || N[2] != x) {
ans+... | 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 a[4], k, ans = 0;
int main() {
scanf("%d%d", &k, &a[1]);
a[2] = a[3] = a[1];
if (a[1] + a[2] > k) {
printf("3");
return 0;
}
while (1) {
sort(a + 1, a + 4);
if (a[1] + a[2] > k)
break;
else {
ans++;
a[1] = min(a[3] + 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 | #include <bits/stdc++.h>
using namespace std;
struct sjx {
int b[3];
sjx(int x) {
for (int i = 0; i < 3; i++) b[i] = x;
}
bool ok(int x) {
for (int i = 0; i < 3; i++)
if (b[i] != x) return false;
return true;
}
void change(int x) {
sort(b, b + 3);
int MAX = b[1] + b[2] - 1;
b[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 C712 {
public static void main(String... xxx){
Scanner sc = new Scanner(System.in);
int x = sc.nextInt(), y = sc.nextInt();
int ans = 0;
int a = y, b = y, c = y;
while (true)
{
if (a >= x && b >= x && c >= x){System... | 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 qmin(int a, int b, int c) {
int d = min(a, min(b, c));
if (a == d) return 1;
if (b == d) return 2;
if (c == d) return 3;
}
int main() {
int x, y;
int ans = 0;
scanf("%d %d", &x, &y);
int a = y, b = y, c = y;
while (1) {
int op = qmin(a, b, 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;
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
int x, y, e[3];
int calc(int a, int b, int c) {
e[0] = a, e[1] = b, e[2] = c;
sort(e, e + 3);
int ret = 0;
while (e[2] != y) {
e[2] = max(y, e[1] - e[0] + 1);
sort(e, e + 3);
++ret;
}
return ret;
}
int ... | 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.*;
import java.util.*;
// this is not good for reading double values.
public class third {
static long m = 100000007;
public static void main(String[] args) throws IOException {
Reader r = new Reader();
PrintWriter o = new PrintWriter(System.out, false);
// PrintWriter o = new PrintWriter(new ... | 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 itertools
import bisect
# import math
from collections import defaultdict
import os
import sys
from io import BytesIO, IOBase
# sys.setrecursionlimit(10 ** 5)
ii = lambda: int(input())
lmii = lambda: list(map(int, input().split()))
slmii = lambda: sorted(map(int, input().split()))
li = lambda: list(input())
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 | import java.io.*;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputStream is;
OutputStream os;
try {
is = new FileInputStream("input.txt");
... | 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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | 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 | a, b = map(int, input().split())
if(a> b):
a, b =b, a
l = [a, a, a]
# print(l)
ans = 0
while(True):
if(sum(l) == 3*b):
break
for i in range(3):
if(l[i]<b):
temp = sum(l)-l[i]
l[i] = min(b, temp-1)
ans +=1
if(sum(l) == 3*b):
break
... | 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 eps = 1e-9;
int main() {
int num1, num2, cnt, a, b, c;
cin >> num1 >> num2;
a = b = c = num2;
cnt = 0;
while (1) {
if (a >= num1 && b >= num1 && c >= num1) {
cout << cnt << endl;
break;
}
cnt++;
if (cnt % 3 == 1) {
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 | 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.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution ... | 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, raw_input().split(' '))
i = j = k = y
c = 0
while i != x or j != x or k != x:
if i == x:
c =c
elif x>j+k-1:
i = j+k-1
c += 1
elif x<j+k-1:
i = x
c += 1
if j == x:
c = c
elif x>i+k-1:
j = i+k-1
c += 1
elif x<i+k-1:
j = x
c += 1
if k == x:
c = c
elif x>i+j-1:
k = i+j-1
... | 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 | end,start=map(int,raw_input().split())
sides=[]
for i in range(3):
sides.append(start)
count=0
while(1):
#print sides
if(sides[0],sides[1],sides[2])==(end,end,end):
break
sides.sort()
sides[0]=min(sides[1]+sides[2]-1,end)
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;
const int MAX = 1e5 + 9;
const long long int inf = INT_MAX;
bool cmp(pair<int, int> &a, pair<int, int> &b) { return (a.first > b.first); }
vector<pair<int, int> > adj[MAX];
long long int dis[MAX];
int par[MAX];
int main() {
int q;
int n, m;
int a[MAX];
int x, y;
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 | x, y = map(int, input().split())
arr, res = [y, y, y], 0
while arr[0] < x:
res += 1
arr[0] = min(arr[1] + arr[2] - 1, x)
arr.sort()
print(res)
| 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 | lst=list(map(int,input().split()))
y=lst[1]
x=lst[0]
res=0
ba,bc,bd=y,y,y
while True:
if ba>=x and bb>=x and bc>=x:
print(res)
break
res+=1
if res%3==0:
ba=bb+bc-1
if res%3==1:
bb=ba+bc-1
if res%3==2:
bc=bb+ba-1
| PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.