static void Solve() { Scan sc = new Scan(); write wr = new write(); var k = sc.intarr; int n = k[0]; var s = sc.chararr; bool han = false; foreach (var x in s) { if (x == 'Y') { han = true; } } if (han) { wr.wri("Four"); } else { wr.wri("Three"); } }
//static long GCD(long x,long y) //{ // if (y == 0) return x; // return GCD(y, x % y); //} //static long LCM(long x,long y) //{ // return x * y / GCD(x, y); //} //static int keta(int x) //{ // string s = x.ToString(); // return s[s.Length - 1]-'0'; //} static void Solve() { Scan sc = new Scan(); write wr = new write(); int N = sc.intarr[0]; if (N == 0) { wr.wri(0); return; } string s = ""; while (N != 0) { if (N % 2 != 0) { N = (N - 1) / -2; s = "1" + s; } else { N /= -2; s = "0" + s; } } wr.wri(s); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var t = sc.intarr; int h = t[0]; int w = t[1]; bool ans = true; char[,] s = new char[h + 2, w + 2]; for (int i = 0; i < h + 2; ++i) { string ss = ""; if (i != h + 1 && i != 0) { ss = sc.str; } for (int j = 0; j < w + 2; ++j) { if (i == 0 || i == h + 1 || j == 0 || j == w + 1) { s[i, j] = '.'; } else { s[i, j] = ss[j - 1]; } } } for (int i = 1; i < h + 1; ++i) { for (int j = 1; j < w + 1; ++j) { if (s[i, j] == '#' && s[i - 1, j] == '.' && s[i + 1, j] == '.' && s[i, j - 1] == '.' && s[i, j + 1] == '.') { ans = false; } } } if (ans) { wr.wri("Yes"); } else { wr.wri("No"); } }
static void Solve() { Scan sc = new Scan(); write wr = new write(); bool ac = true; string S = sc.str; if (S[0] != 'A') { ac = false; } bool isC = false; int Ci = -1; for (int i = 2; i < S.Length - 1; ++i) { if (!isC && S[i] == 'C') { isC = true; Ci = i; } else if (isC && S[i] == 'C') { ac = false; } } if (!isC) { ac = false; } for (int i = 0; i < S.Length; ++i) { if (i != 0 && i != Ci) { if (S[i] < 'a') { ac = false; } } } if (ac) { wr.wri("AC"); } else { wr.wri("WA"); } }
static void Solve() { Scan sc = new Scan(); write wr = new write(); int n = sc.intarr[0]; if (n % digitsum(n) == 0) { wr.wri("Yes"); } else { wr.wri("No"); } }
static void Solve() { Scan sc = new Scan(); write wr = new write(); int N = sc.intarr[0]; int[] dp = new int[N + 1]; dp[0] = 0; for (int i = 1; i <= N; ++i) { dp[i] = INF; } for (int i = 1; i <= N; ++i) { for (int j = 0; j < 12; ++j) { if (i - num[j] >= 0) { dp[i] = Math.Min(dp[i], dp[i - num[j]] + 1); } } } wr.wri(dp[N]); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); int n = sc.intarr[0]; if (n <= 999) { wr.wri("ABC"); } else { wr.wri("ABD"); } }
static void Solve() { Scan sc = new Scan(); write wr = new write(); int n = sc.intarr[0]; if (n % 3 == 0) { wr.wri("YES"); } else { wr.wri("NO"); } }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var s = sc.longarr; if (s[2] <= s[0] + s[1]) { wr.wri("Yes"); } else { wr.wri("No"); } }
static void Solve() { Scan sc = new Scan(); write wr = new write(); long ans = INF; var x = sc.intarr; int D = x[0]; int G = x[1]; long[] p = new long[D]; long[] c = new long[D]; for (int i = 0; i < D; ++i) { var y = sc.intarr; p[i] = y[0]; c[i] = y[1]; } for (int bit = 0; bit < (1 << D); ++bit) { long sum = 0; long num = 0; for (int i = 0; i < D; ++i) { if (((bit >> i) & 1) == 1) { sum += c[i] + p[i] * 100 * (i + 1); num += p[i]; } } if (sum >= G) { ans = Math.Min(ans, num); } else { for (int i = D - 1; i >= 0; --i) { if (((bit >> i) & 1) == 1) { continue; } for (int k = 0; k < p[i]; ++k) { if (sum >= G) { break; } sum += 100 * (i + 1); ++num; } } ans = Math.Min(ans, num); } } wr.wri(ans); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); int n = sc.intarr[0]; var k = sc.intarr; int d = k[0]; int x = k[1]; int ans = x; for (int i = 0; i < n; ++i) { int a = sc.intarr[0]; for (int j = 1; j <= d; j += a) { ans++; } } wr.wri(ans); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); int[] X = sc.intarr; int ans1 = -1; int ans2 = 1; for (int i = 0; i <= 100; ++i) { for (int j = 0; j <= 100; ++j) { for (int k = 0; k <= 100; ++k) { for (int l = 0; l <= 100; ++l) { int x = 100 * X[0] * i + 100 * X[1] * j; int y = X[2] * k + X[3] * l; if (x == 0 || x + y > X[5] || x * X[4] < y * 100) { continue; } else if (ans1 * (x + y) <= ans2 * y) { ans1 = y; ans2 = x + y; } } } } } wr.wri(ans2 + " " + ans1); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var p1 = sc.longarr; long n = p1[0]; var a = sc.longarr; Array.Sort(a); Array.Reverse(a); long ans1 = 0, ans2 = 0;; for (int i = 0; i < a.Length; ++i) { if (i % 2 == 0) { ans1 += a[i]; } else { ans2 += a[i]; } } wr.wri(ans1 - ans2); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); int[] s = sc.intarr; int N = s[0]; if (N % 2 == 0) { wr.wri(N); } else { wr.wri(N * 2); } }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var X = sc.intarr; wr.wri((X[0] - 1) * (X[1] - 1)); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); int n = sc.intarr[0]; wr.wri((n + 1) / 2); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var x = sc.intarr; wr.wri(x.Max() - x.Min()); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var s = sc.intarr; int a = s[0]; int b = s[1]; if (a > b) { wr.wri(a - 1); } else { wr.wri(a); } }
static void Solve() { Scan sc = new Scan(); write wr = new write(); int[] N = sc.intarr; int A = N[0]; int B = N[1]; if (Math.Max(A, B) <= 8) { wr.wri("Yay!"); } else { wr.wri(":("); } }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var x = sc.intarr; wr.wri(x[0] - x[1] + 1); }
//static long GCD(long x,long y) //{ // if (y == 0) return x; // return GCD(y, x % y); //} //static long LCM(long x,long y) //{ // return x * y / GCD(x, y); //} //static int keta(int x) //{ // string s = x.ToString(); // return s[s.Length - 1]-'0'; //} static void Solve() { Scan sc = new Scan(); write wr = new write(); var x = sc.intarr; int N = x[0]; int K = x[1]; if (N % K == 0) { wr.wri(0); } else { wr.wri(1); } }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var s = sc.intarr; int n = s[0]; wr.wri(n / 3); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var s = sc.intarr; int a = s[0]; int b = s[1]; int x = s[2]; if (a + b >= x && a <= x) { wr.wri("YES"); } else { wr.wri("NO"); } }
//static long GCD(long x,long y) //{ // if (y == 0) return x; // return GCD(y, x % y); //} //static long LCM(long x,long y) //{ // return x * y / GCD(x, y); //} //static int keta(int x) //{ // string s = x.ToString(); // return s[s.Length - 1]-'0'; //} static void Solve() { Scan sc = new Scan(); write wr = new write(); int N = sc.intarr[0]; for (int i = 0; i <= 25; ++i) { for (int j = 0; j < 20; ++j) { if (i * 4 + j * 7 == N) { wr.wri("Yes"); return; } } } wr.wri("No"); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var s = sc.intarr; int a = s[0]; int b = s[1]; wr.wri(Math.Max(Math.Max(a + b, a - b), a * b)); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var s = sc.longarr; long a = s[0]; long b = s[1]; long k = s[2]; for (long i = a; i <= Math.Min(a + k - 1, b); i++) { wr.wri(i); } for (long i = Math.Max(b - k + 1, Math.Min(a + k - 1, b) + 1); i <= b; ++i) { wr.wri(i); } }
static void Solve() { Scan sc = new Scan(); write wr = new write(); string s = sc.str; string t = sc.str; for (int i = 0; i < s.Length; ++i) { string u = s.Substring(0, i); string v = s.Substring(i); if (t == v + u) { wr.wri("Yes"); return; } } wr.wri("No"); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); int[] s = sc.intarr; int N = s[0]; var A = sc.intarr; wr.wri(Math.Abs(A.Min() - A.Max())); }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var s = sc.chararr; Array.Sort(s); var a = new string(s); if (a == "abc") { wr.wri("Yes"); } else { wr.wri("No"); } }
static void Solve() { Scan sc = new Scan(); write wr = new write(); var t = sc.intarr; int a = t[0]; int b = t[1]; int c = t[2]; int d = t[3]; if (Math.Abs(a - c) <= d || (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d)) { wr.wri("Yes"); } else { wr.wri("No"); } }