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
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int P(long long n, long long k, long long d1, long long d2) { long long x1, x2, x3, a, b, c, d, f; if (n % 3 != 0) return 0; x1 = (k + 2 * d1 + d2) / 3; x2 = x1 - d1; x3 = x2 - d2; if (x1 + x2 + x3 != k) return 0; if (x1 > n / 3 || x2 > n / 3 || x3 > n / 3) re...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long int max(long long int a, long long int b, long long int c) { return max(max(a, b), c); } long long int min(long long int a, long long int b, long long int c) { return min(a, min(b, c)); } int main() { ios_base::sync_with_stdio(false); int TC; cin >> TC; ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.*; public class Myclass{ static ArrayList[] a=new ArrayList[200001]; static boolean f(long a,long b,long c,long maxi) { if(a+b+c!=can) return false; return (a>=0 && a<=maxi &&b>=0 && b<=maxi && c>=0 && c<=maxi ); } ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
cas = int (input ()) while cas > 0 : cas -= 1 n , k , a , b = map (int , raw_input ().split ()) ok = False for i in xrange (-1 , 2 , 2) : for j in xrange (-1 , 2 , 2) : t = k - 2 * b * j - a * i if t % 3 == 0 : p = sorted ([t / 3 , t / 3 + b * j , t / 3 + ...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
def checa(s1,s2): if (2*d1*s1 + d2*s2 + k) % 3 != 0: return False x1 = (2*d1*s1 + d2*s2 + k) / 3 x2 = x1 - d1*s1 x3 = x2 - d2*s2 if x1 >= 0 and x1 <= k: if x2 >= 0 and x2 <= k: if x3 >= 0 and x3 <= k: if x1 <= n/3 and x2 <= n/3 and x3 <...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); while (t--) { long long n, k, d1, d2; scanf("%lld %lld %lld %lld", &n, &k, &d1, &d2); if (n % 3) { printf("no\n"); continue; } bool flag = false; for (int i = -1; i <= 1; i += 2) for (int j...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
function trim(s) { return s.replace(/^\s+|\s+$/gm, ''); } function tokenize(s) { return trim(s).split(/\s+/); } function tokenizeIntegers(s) { var tokens = tokenize(s); for (var i = 0; i < tokens.length; i += 1) { tokens[i] = parseInt(tokens[i], 10); }; return tokens; } function feasible(n, k, d1, d2) { if ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import javax.swing.text.MutableAttributeSet; import java.awt.image.AreaAveragingScaleFilter; import java.io.*; import java.util.*; public class Solution { public static long h,z,f; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); wh...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> long long exp(long long x, long long y, long long p) { long long res = 1; while (y) { if (y % 2) res = (res * x % p) % p; x = (x * x) % p; y /= 2; } return res; } long long expo(long long x, long long y) { long long res = 1; while (y) { if (y % 2) res = (res * x % ((...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; void solve() { if (n % 3) { printf("no\n"); return; } long long t1 = k + d1 - d2; long long t2 = k - d1 + d2; long long t3 = k - d1 - d2; long long t4 = k + d1 + d2; if (t1 % 3 == 0) { long long b1 = t1 / 3; if (b1 + d2 ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.Scanner; /* 5 3 0 0 0 3 3 0 0 6 4 1 0 6 3 3 0 3 3 3 2 */ public class CFC { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); outer: for(int kase=0;kase<N;kase++) { long n = in.nextLong(); long k = in.nextLong(); long d1= in.nextLong(...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long t, n, k, d1, d2, a, b, c; bool func(long long x, long long y) { long long sum = 2 * x + y; if (k - sum >= 0 && (k - sum) % 3 == 0) { a = (k - sum) / 3; b = a + x; c = b + y; if (a < 0 || b < 0 || c < 0) return 0; long long maxx = max(a, max...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; while (n--) { long long total, played, gamestogo; cin >> total >> played; gamestogo = total - played; long long d1, d2; cin >> d1 >> d2; int status = 0; long long a = d1 + d2; long long b = d2; lo...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.math.*; import java.util.*; import java.util.concurrent.*; public class P451C { final int [][] s = {{-1, -1}, {-1, 1}, {1, -1}, {1, 1}}; final double EPS = 1e-6; @SuppressWarnings("unchecked") public void run() throws Exception { int t = nextInt(); while ((t--) > 0) { ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); while (t--) { long long n, k, d1, d2; cin >> n >> k >> d1 >> d2; if (n % 3 != 0) printf("no\n"); else { long long w1, w2, w3; w2 = (k - d1 + d2) / 3; w1 = d1 + w2; w3 = k - w1 - w2; ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n, k, d1, d2; cin >> n >> k >> d1 >> d2; if (n % 3 != 0) cout << "no\n"; else { long long p = n / 3; long long l = d1 + d2 + k; if (l >= 0 && l % 3 == 0) { long long ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
rl = lambda: raw_input().strip() cases = int(rl()) for cc in xrange(cases): n, k, d1, d2 = map(int, rl().split()) def test(d1, d2): b3 = k - d1 - d2 if b3 % 3 > 0: return False b = b3 / 3 a = b + d1 c = b + d2 return min([a, b, c]) >= 0 and max([a, b, c]) <= n / ...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
from sys import stdin from math import fabs t = int(stdin.readline()) for _ in range(t): n, k, d1, d2 = map(int, stdin.readline().split()) flg = False w = k+2*d1+d2 a = w//3 if w >= 0 and w%3 == 0 and a >= d1+d2 and 2*d1 + d2 <= n-k and (n-k-2*d1-d2)%3 == 0: flg = True w = k+2*d1-d2 ...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
t = int(raw_input()) while t>0: n,k,d1,d2 = map(int,raw_input().split()) if n%3 != 0: print "no" else: flag = False sv = n/3 if (k+d2-d1)%3 == 0: y = (k+d2-d1)/3 x = d1+y z = y - d2 if x<=sv and y <= sv and z <= sv and x >= 0 an...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.*; import java.io.*; public class Main { BufferedReader in; StringTokenizer str = null; PrintWriter out; private String next() throws Exception{ while (str == null || !str.hasMoreElements()) str = new StringTokenizer(in.readLine()); return str.nextToken(); } private int nextInt() thr...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
// practice with rainboy import java.io.*; import java.util.*; public class CF451C extends PrintWriter { CF451C() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF451C o = new CF451C(); o.main(); o.flush(); } boolean check(long n, long k, long x, long y) { l...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { long long n, k, d1, d2; cin >> n >> k >> d1 >> d2; bool flag = false; for (long long s1 = -1; s1 <= 1; s1 += 2) { for (int long long s2 = -1; s2 <= 1; s2 += 2) { l...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long n, m, d1, d2, a, b, c, tag; bool chk() { return a >= 0 && a <= n / 3 && b >= 0 && b <= n / 3 && c >= 0 && c <= n / 3 && a + b + c == m; } void init() { tag = 0; if (n % 3) return; a = (m + 2 * d1 + d2) / 3; b = a - d1; c = b - d2; if (chk())...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int check(long long n, long long k, long long d1, long long d2) { long long div = n / 3; if ((k - d1 + d2) % 3) return 0; long long B = k - (d1 - d2); B /= 3; if (B < 0 || B > div || B > k) return 0; long long A = d1 + B; if (A < 0 || A > div || A > k) return ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); int main() { int t; cin >> t; while (t--) { long long n, k, d1, d2, x1, x2, x3, D1, D2; int f = 0; cin >> n >> k >> d1 >> d2; if (n % 3 != 0) { cout << "no" << endl; continue; } else { for (int i = -1...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; bool check(long long u, long long t) { if (u % 3 || u > n) return false; return u / 3 >= t; } bool judge() { if (n % 3) return false; if (check(n - k + d1 + d2 * 2, d1 + d2)) return true; if (check(n - k + 2 * d1 + d2, d1 + d2)) return true...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
for i in range(int(input())): n, u, a, b = map(int, input().split()) if n % 3: print('no') else: if a > b: a, b = b, a p, q = a + b, 2 * b - a s, r, v = p + a, p + b, n - u t = [(p, q), (q, p), (s, r), (r, s)] print('no' if all(x > u or (x - u) % 3 or y > v or (y - v)...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; long long modexp(long long x, long long n) { if (n == 0) return 1; if (n % 2 == 0) { long long y = modexp(x, n / 2) % mod; return (y * y) % mod; } return (x * modexp(x, n - 1) % mod) % mod; } long long modularExponentiation(long long...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int T = in.nextInt(); long n, k, d1, d2; while (T-- > 0) { n = in.nextLong(); k = in.nextLong(); d1 = in.nextLong(); d2 = in.nextLong(); ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
def f(x, y, a, b): return x > a or y > b or (a - x) % 3 or (b - y) % 3 def g(x, y, a, b): return f(x, y, a, b) and f(x, y, b, a) for i in range(int(input())): n, u, a, b = map(int, input().split()) v, s, t = n - u, a + b, 2 * b - a if b > a else 2 * a - b print('no' if g(s, t, u, v) and g(s + a, s + b, u, v...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int t; long long n, k, a, b; bool check(long long x, long long y, long long z) { if (k - x - y - z < 0 || (k - x - y - z) % 3 != 0) return 0; long long mx = max(max(x, y), z); if ((n - (k + mx * 3 - x - y - z)) < 0 || ((n - (k + mx * 3 - x - y - z)) % 3 != 0)) ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
T = int(raw_input()) for _ in range(T): n, k, d1, d2 = map(int, raw_input().split()) if n % 3 != 0: flag = False else : m = n / 3 flag = False def test(x): return x >= 0 and x <= m if (k-d1-d2) % 3 == 0: t = (k-d1-d2) / 3 if test(t) and test(t+d1) and test(t+d2): flag = True if...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; bool func(long long int n, long long int k, long long int a, long long int b) { k -= a + b; if (k % 3) return false; k /= 3; if (k >= 0 && k <= n && a + k >= 0 && a + k <= n && b + k >= 0 && b + k <= n) return true; else return false; } int main() { ios_...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-11; long long n, k; bool solveIt(long long d1, long long d2) { if ((k - d1 + d2) % 3 != 0) return false; long long Y = (k - d1 + d2) / 3; long long X = d1 + Y; long long Z = Y - d2; if (X >= 0 && Y >= 0 && Z >= 0...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int t; long long n, k, d1, d2; int f[] = {1, -1}; int main() { cin >> t; while (t--) { cin >> n >> k >> d1 >> d2; long long rem = n - k; long long t1 = 100 * n; int flag = 0; for (int i = 0; i < 2; ++i) { long long t2 = t1 + f[i] * d1; fo...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long int n[110000], k[110000], d1[110000], d2[110000]; int main() { int t = 0; cin >> t; for (int i = 1; i <= t; i++) { cin >> n[i] >> k[i] >> d1[i] >> d2[i]; } for (int i = 1; i <= t; i++) { int ans = 0; long long int w1, w2, w3; if (n[i] % 3...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 5005; const int INF = 1e9 + 9; long long n, k, d1, d2, m; long long kk; int main() { int t; scanf("%d", &t); for (int it = 1; it <= t; it++) { scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2); n -= k; m = n; m -= d1; m -= d2; kk...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
# -*- coding: utf-8 -*- import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll t = int(raw_input()) for loop in xrange(t): n, k, d1, d2 = map(int, raw_input().split()) ok = False for i in xrange(4): x = 1 if i % 2 else -1 y = 1 if i / 2 else -1 z = k + x...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.StringTokenizer; public class PredictOutcomeOfTheGame { public static void main(String[] args) { MyScanner sc = new MyScanner(); int T = sc.nextInt(); StringBuilde...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T> T POW(T B, T printf) { if (printf == 0) return 1; if (printf & 1) return B * POW(B, printf - 1); else return (POW(B, printf / 2) * POW(B, printf / 2)); } template <typename T> T BIGMOD(T b, T p, T m) { if (p == 0) return 1; else i...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long t, i, n, k, d1, d2, x1, x2, x3, maxim, nr; int ans[100001]; int main() { cin >> t; for (i = 1; i <= t; i++) { cin >> n >> k >> d1 >> d2; x1 = (k + 2 * d1 + d2) / 3; x2 = (k - d1 + d2) / 3; x3 = (k - d1 - 2 * d2) / 3; if (x1 + x2 + x3 == k &...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int func(long long n, long long k, long long p1, long long p2) { if (n % 3 != 0) return 0; long long x2, x3, x1, d1, d2; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (i == 0 || j == 0) continue; d1 = i * p1; d2 = j * p2; ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2, w[3]; long long mat[3][4]; long long det(long long m[3][3]) { long long ans = 0; for (int i = 0; i < 3; i++) { long long prod = 1; for (int j = 0; j < 3; j++) { prod *= m[j][(j + i) % 3]; } ans += prod; } for (int i = 0;...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 10, MOD = 1e9 + 7, nax = 1000005; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { long long n, k, d1, d2; cin >> n >> k >> d1 >> d2; if (n % 3 != 0) { cout << "no\n"; continu...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
from sys import * t=int(stdin.readline()) for i in range(t): n,k,d1,d2=(int(z) for z in stdin.readline().split()) if (k-2*d1-d2>=0 and (k-2*d1-d2)%3==0 and n-2*d2-d1-k>=0 and (n-2*d2-d1-k)%3==0) or (k-2*d2-d1>=0 and (k-2*d2-d1)%3==0 and n-2*d1-d2-k>=0 and (n-2*d1-d2-k)%3==0) or (k-d1-d2>=0 and (k-d1-d2)%3==0 ...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.ArrayList; import java.util.StringTokenizer; public class C451 { public static BufferedReader in; public static Pr...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int t; long long n, k, d1, d2; void solve() { long long x, y, z; if ((k - d1 * 2 - d2) >= 0 && (k - d1 * 2 - d2) % 3 == 0) { x = (k - d1 * 2 - d2) / 3; y = x + d1; z = y + d2; if (x <= n / 3 && y <= n / 3 && z <= n / 3) if (x >= 0 && y >= 0 && z >=...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.Scanner; public class TestC { public static void main (String args[]) { Scanner sc = new Scanner(System.in); int t =sc.nextInt(); for (int i=0; i<t; i++){ //System.out.println("i="+i); long n =sc.nextLong(); long k = sc.nextL...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long int n, k, d1, d2; bool check(long long int a, long long int b, long long int c) { if (n % 3 != 0) return false; long long int mini = min(a, min(b, c)); a -= mini; b -= mini; c -= mini; long long int pluss = k - a - b - c; if (pluss % 3 != 0) return f...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; for (int i = 0; i < N; i++) { long long n, k, d1, d2; cin >> n >> k >> d1 >> d2; long long gleft = n - k; if (((max(d1, d2) + abs(d1 - d2)) <= gleft) && (!((max(d1, d2) + abs(d1 - d2) - gleft) % 3)) && ((d1 + d2) <...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
from sys import * t=int(stdin.readline()) mm,mmm,mmmm,m=0,0,0,0 for i in range(t): n,k,d1,d2=(int(z) for z in stdin.readline().split()) m=d1+d2 mm=2*max(d1,d2)-min(d1,d2) mmm=2*d1+d2 mmmm=2*d2+d1 if (k-mmm>=0 and (k-mmm)%3==0 and n-mmmm-k>=0 and (n-mmmm-k)%3==0) or (k-mmmm>=0 and (k-mmmm)%3==0 ...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class PredictOutcomeOfTheGame { void solve() { int T = in.nextInt(); while (T-- > 0) { long n = in....
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
def solve(n, k, d1, d2): if n % 3 > 0: return False n3 = n // 3 if (k + d1 + d2) % 3 == 0 and (k + d1 + d2) // 3 <= n3: x = (k + d1 + d2) // 3 if x - d1 >= 0 and x - d2 >= 0: return True if (k + 2 * d1 + d2) % 3 == 0 and (k + 2 * d1 + d2) // 3 <= n3: x = (k + ...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; bool check(long long w1, long long w2, long long w3) { long long MIN = w1 < w2 ? w1 : w2; MIN = MIN < w3 ? MIN : w3; w1 -= MIN; w2 -= MIN; w3 -= MIN; long long u = k - (w1 + w2 + w3); if (u < 0 || u % 3 != 0) return 0; long long MAX =...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> const int inf = 0xfffffff; const long long INF = 1ll << 61; using namespace std; long long n, k, x, y, z; bool cal(long long d1, long long d2) { if (k - 2 * d2 - d1 < 0) return false; if ((k - 2 * d2 - d1) % 3) return false; z = (k - 2 * d2 - d1) / 3; y = d2 + z; x = d1 + y; if (x <...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; bool bs(long long n, long long k, long long d1, long long d2, long long sign1, long long sign2) { long long lbound = -min(min(0LL, d1 * sign1), min(0LL, d1 * sign1 + d2 * sign2)); long long rbound = n / 3LL - max(max(0LL, d1 * sign1), max(0LL, d1 * s...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; public class C258_C { public static void main(String []args) { FastReader fr = new FastReader(); long t = fr.nextLong(); for (int i = 0; i < t; i++) { long n = fr.nextLong(); ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } long long n...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class GameOutcome { static boolean test = false; public static void main(String[] args) throws IOException { initReader(); logTime(""); while (true) { l...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> const int INF = 100000000; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; using namespace std; int t; long long n, k; bool ok(long long d1, long long d2) { if (n % 3) return false; long long x1 = k + 2 * d1 + d2; if (x1 % 3 != 0) return false; if (x1 < 0) return false; x1 /= 3;...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int compare(const void *a, const void *b) { int *p = (int *)a; int *q = (int *)b; if (p[0] == q[0]) return p[1] - q[1]; return p[0] - q[0]; } long long int i, j, n, m, k, d1, d2, a[3] = {0}; int check() { j = n - k; j -= abs(a[0] - a[1]); long long int mx = ma...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long int i, j, k, n, m, s, sa, l, a, b, t[3], kk; bool f(long long t1, long long t2, long long t3, long long n, long long m) { long long int t[3] = {t1, t2, t3}; sort(t, t + 3); m -= t[0] + t[1] + t[2]; if (t[0] < 0) m += t[0] * 3; if (m < 0 || (m > 0 && (m %...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#------------------------template--------------------------# import os import sys from math import * from collections import * # from fractions import * # from heapq import* from bisect import * from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w')...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long long t, n, i, k, d1, d2; cin >> t; for (i = 0; i < t; i++) { cin >> n >> k >> d1 >> d2; if (n == k && d1 != 0 && d2 != 0) cout << "no" << endl; else if ((n - k - (d1 + 2 * d2)) >= 0 && (n - k - (d1 + 2 * d2)) % 3 == 0 && ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class C { BufferedReader reader; StringTokenizer tokenizer; PrintWriter out; public void solve() throws IOException { int T = nextInt(); f...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.util.*; import java.math.*; public class p451c { public static void main(String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(br.readLine()); for (int t = 1; t <= T; t++) { ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int T; long long N, K, D1, D2; inline bool check(long long n, long long r) { if (r < n) return false; return (r - n) % 3 == 0; } int main() { cin >> T; for (int cas = 1; cas <= T; cas++) { cin >> N >> K >> D1 >> D2; long long MAXD = max(D1, D2); long lon...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
from sys import * t=int(stdin.readline()) for i in range(t): n,k,d1,d2=(int(z) for z in stdin.readline().split()) vars=[[2*d1+d2,2*d2+d1],[2*d2+d1,2*d1+d2],[2*max(d1,d2)-min(d1,d2),d1+d2], [d1+d2,2*max(d1,d2)-min(d1,d2)]] y=False for i in vars: if i[0]<=k and i[0]%3==k%3 and n-k-i[1]>=0 and (n-...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, d1, d2, ans, i, j, a1, a2, a3; int t; scanf("%d", &t); while (t--) { scanf("%lld %lld %lld %lld", &n, &k, &d1, &d2); if (n % 3 != 0) { printf("no\n"); continue; } j = n / 3; i = ((-2) * d1) + d2; i = k...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long a[4], n, i, k, d1, d2, t, mask, mn; void solve() { cin >> n >> k >> d1 >> d2; for (mask = 0; mask < 4; mask++) { a[1] = a[2] = a[3] = 0; if ((mask >> 0LL) % 2 == 0) a[1] -= d1; else a[1] += d1; if ((mask >> 1LL) % 2 == 0) a[3]...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
# # Uian Sol Gorgonio <sol.uian@gmail.com> # Aug 10 2014 # Predict Outcome of the Game # http://codeforces.com/contest/451/problem/C # # Math # def case(sig1, sig2): if (2*d1*sig1 + d2*sig2 + k) % 3 != 0: return False x1 = (2*d1*sig1 + d2*sig2 + k) / 3 x2 = x1 - d1*sig1 x3 = x2 - d2*sig2 ...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.*; import java.io.*; public class C implements Runnable { public void solve() throws IOException { int T = nextInt(); for(int i = 0; i < T; i++){ long N = nextLong(); long K = nextLong(); long d1 = nextLong(); ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> const double PI = acos(-1.0); using namespace std; int a[100010]; int main() { int CASE; scanf("%d", &CASE); while (CASE--) { long long n, k, d1, d2; scanf("%I64d %I64d %I64d %I64d", &n, &k, &d1, &d2); if (n % 3 != 0) { printf("no\n"); continue; } if ((k - ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.math.BigInteger; import java.util.*; public class CF { FastScanner in; PrintWriter out; boolean can(long n, long k, long d1, long d2) { long tmp = k - d2 - d1 -d1; if (tmp % 3 != 0 || tmp < 0) return false; tmp /= 3; long[] vals = new long[]{tmp, tmp + d1, tmp + d1 + d2}; ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.util.*; public class C implements Runnable { FastReader sc; PrintWriter out; long mod = (long)1e9 + 7; /* x1+x2+x3 = k |x1-x2| = d1 |x2-x3| = d2 2*x1 + x3 = d1+k x1 - x3 = d1+d2 x1 = (2*d1+d2+k)/3 */ void solve() { int tc = sc.ni(); outer: while(tc-- ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
t=input() for i in range(0,t): n,k,d1,d2=(int(x) for x in raw_input().split()) a,b,c=d1,0,-d2 a1,b1,c1=d1,0,d2 res=0 ost=n-k d1,d2=max(d1,d2),min(d1,d2) if 2*d1+d2<=k: if (k-2*d1-d2)%3==0: if 2*d2+d1<=ost and (ost-2*d2-d1)%3==0: res=1 ...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const int MOD(1000000007); const int INF((1 << 30) - 1); const int MAXN(); long long n, k, d1, d2, c1, c2; bool f1() { c1 = k - d1 - d2; c2 = n - k - d1 - 2 * (d2 - d1); return c1 >= 0 && c2 >= 0 && c1 % 3 == 0 && c2 % 3 == 0; } bool f2() { c1 = k - 2 * d2 - d1; c...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#!/usr/bin/python import sys from math import * def Ni(): return tuple(map(int, sys.stdin.readline().split())) t = Ni()[0] for i in range(t): n, k, d1, d2 = Ni() if n % 3 != 0: print "no" continue def check(d1, d2): ww = k - d1 - 2 * d2 if ww < 0 or ww % 3 != 0: ...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.Scanner; public class C { public static void main(String[]args){ Scanner scan = new Scanner(System.in); int t = scan.nextInt(); long n, k,d1,d2; boolean valid; for(int i=0;i<t;i++){ valid = false; n = scan.nextLong(); k =...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class G { static class Scanner{ BufferedReader br=null; StringTokenizer tk=null; public Scanner(){ br=new BufferedReader(new InputStreamReader(System.in)); } public Str...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long t, n, k, d1, d2; long long x2[4], x3[4], x1[4]; int main() { cin >> t; for (int i = 0; i < t; i++) { cin >> n >> k >> d1 >> d2; x2[0] = (k + d2 - d1) / 3; x3[0] = x2[0] - d2; x1[0] = x2[0] + d1; x2[1] = (k - (d1 + d2)) / 3; x3[1] = x2[1...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
t=int(raw_input()) for i in range(t): n,k,d1,d2=map(int,raw_input().split()) l=[] if((k-d1-2*d2)%3==0 and k-d1-2*d2>=0 ): w=[] w3=(k-d1-2*d2)/3 w1=w3+d2+d1 w2=w3+d2 if(w2>=0 and w1>=0): w.append(w1) w.append(w2) w.append(w3) ...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long i, j, k, N, M, K, a, b, c, d, n, d1, d2, q; long long tmax(long long a, long long b, long long c) { return max(max(a, b), c); } long long tmin(long long a, long long b, long long c) { return min(min(a, b), c); } long long poss(long long n, long long l, long lo...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.List; imp...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C { private static long n, k; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in))...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { int n; cin >> n; long long a[4]; long long t, k, d1, d2; bool d; for (long long i = 0; i < n; i++) { cin >> t >> k >> d1 >> d2; a[0] = (((d1) > (d2)) ? (d1) : (d2)) + ((...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long long j, t, i, a, n, k, d1, d2; scanf("%I64d", &t); while (t--) { scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2); bool f = 0; if (n % 3 == 0) { n /= 3; for (i = -1; i <= 1; i += 2) for (j = -1; j <= 1; j += 2) { ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int TESTS = 1; cin >> TESTS; while (TESTS--) { long long n, k, d1, d2; cin >> n >> k >> d1 >> d2; bool flag = false; long long x = n - k; long long y = k; if (y >= d1...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int T; long long N, K, d1, d2; bool Try(long long d1, long long d2, long long N) { long long d3 = d1 + d2; long long x, y, z; if ((N + d1 + d3) % 3 != 0) return 0; x = (N + d1 + d3) / 3; y = x - d1; z = y - d2; if (x >= 0 && y >= 0 && z >= 0 && (x + y + z) == ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import sys import math MAXNUM = math.inf MINNUM = -1 * math.inf ASCIILOWER = 97 ASCIIUPPER = 65 def getInt(): return int(sys.stdin.readline().rstrip()) def getInts(): return map(int, sys.stdin.readline().rstrip().split(" ")) def getString(): return sys.stdin.readline().rstrip() def printOutput(ans)...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> template <typename T, typename U> inline void swap(T &a, U &b) { a = a ^ b; b = a ^ b; a = a ^ b; } inline void swap(int &a, int &b) { a = a ^ b; b = a ^ b; a = a ^ b; } inline void swap(long long &a, long long &b) { a = a ^ b; b = a ^ b; a = a ^ b; } template <typename T, typ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here MyScanner sc = ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; bool ok(long long n, long long x1, long long x2, long long x3) { return x1 >= 0 && x1 <= n / 3 && x2 >= 0 && x2 <= n / 3 && x3 >= 0 && x3 <= n / 3; } void solve(int test) { long long n, k, d1, d2, x1, x2, x3; cin >> n >> k >> d1 >> d2; if (n % 3 != 0) { ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; void DBG() { cerr << "]" << endl; } template <class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if (sizeof...(t)) cerr << ", "; DBG(t...); } int main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.InputStream; import java.io.PrintStream; import java.util.Arrays; import java.util.Scanner; public class C { Scanner scan; public static void main(String[] args) throws Exception{ InputStream in = System.in; //PrintStream out = new PrintStream(new File(outName)); PrintStream out = System.ou...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n, k, d1, d2; cin >> n >> k >> d1 >> d2; if (n % 3 == 0) { long long nn = n - k; long long a = d1, b = 0, c = d2; long long s = max(d1, d2); if (3 * s - d1 - d2 <= n - k && (n - ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; bool solve(long long n, long long k, long long d1, long long d2) { long long arr[4][3]; arr[0][0] = d1; arr[0][1] = 0; arr[0][2] = d2; arr[1][0] = d1 + d2; arr[1][1] = d2; arr[1][2] = 0; arr[2][0] = 0; arr[2][1] = d1; arr[2][2] = d2 + d1; if (d1 > d2) ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pradyumn */ public class M...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long x, y, z, d1, d2, k, t, n, no; bool posv() { return (x >= 0 && y >= 0 && z >= 0); } void check() { long long p = k; long long arr[3]; arr[0] = x, arr[1] = y, arr[2] = z; long long mx = *max_element(arr, arr + 3); for (int i = 0; i < 3; i++) { p += mx ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 5e3 + 7; const long long mod = 1e9 + 7; int main() { long long t, n, m, d1, d2, mx, mi, s; cin >> t; while (t--) { cin >> n >> m >> d1 >> d2; if ((m - d1 - d2) >= 0 && (m - d1 - d2) % 3 == 0 && (m - d1 - d2) / 3 >= 0) { mx = max(d1,...
CPP