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 | t = int(raw_input())
def check(a, b, c, n, k):
# print a, b, c
val = min(a, b, c)
if val < 0:
a += -val
b += -val
c += -val
# print a, b, c
s = a + b + c
if k < s:
return False
if (k-s) % 3 != 0:
return False
games = n - k
if (games+s) % 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 | /* 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
{
Scanner sc=new Scanner(System.in);
int... | 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;
scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2);
if (n % 3) {
puts("no");
continue;
}
bool ok = false;
for (int s1 = -1; s1 <= 1; s1 += 2) {
for (int 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 | from itertools import product
def try_all(n, k, d1, d2):
for k1, k2 in filter(lambda (k1, k2): (k - k1 - k2) % 3 == 0, set(product((-d1, d1), (-d2, d2)))):
w2 = (k - k1 - k2) / 3
w1 = w2 + k1
w3 = w2 + k2
if w1 >= 0 and w2 >= 0 and w3 >= 0:
winamax = max(w1, w2, 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;
int nTest;
long long n, k, d1, d2;
bool isOK(long long a, long long b, long long c) {
if (a < 0) {
b -= a;
c -= a;
a -= a;
}
if (b < 0) {
c -= b;
a -= b;
b -= b;
}
if (c < 0) {
a -= c;
b -= c;
c -= c;
}
if (a + b + c > k) 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 n, i, j, k, l, t = 1, ans = 0, flag = 0, d1, d2, a, b, c;
bool f(long long a, long long b, long long c, long long n, long long k) {
long long j = k - (a + b + c);
if (j % 3 != 0) return false;
long long x = j / 3;
a += x, b += x, c += x;
if (a < 0 || b <... | 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 bisect import bisect_left as bl #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br #c++ upperbound br(array,element)
#from __future__ import print_function, division #while using python2
def modinv(n,p):
return pow(n,p-2,p)
def calc(a, b, c, r):
# p... | 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 check(long long n, long long k, long long x, long long y, long long z) {
if (k >= x + y + z && (k - (x + y + z)) % 3 == 0) {
n -= k;
n -= z - x;
n -= z - y;
if (n >= 0 && n % 3 == 0) {
return 1;
}
}
return 0;
}
int main() {
int T;
cin... | 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 = 1000000007;
const long long inf = 1e18 + 5;
const long long MX = 303030;
int cox[4] = {1, -1, 0, 0};
int coy[4] = {0, 0, 1, -1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { 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;
bool b;
long long n, k, d1, d2;
void solve(long long d1, long long d2) {
long long x1, x2, x3;
x1 = (2 * d1 + d2 + k) / 3;
x3 = k + d1 - 2 * x1;
x2 = k - x1 - x3;
long long m = max(max(x1, x2), x3);
long long left = n - k - (m - x1) - (m - x2) - (m - x3);
if (... | 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;
int check(long long d1, long long d2) {
if ((k + d1 + d1 + d2) % 3 != 0) return 0;
long long x = (k + d1 + d1 + d2) / 3, y = x - d1, z = k - x - y;
return x >= 0 && y >= 0 && z >= 0 && x <= n / 3 && y <= n / 3 && z <= n / 3;
}
int main() {
in... | 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;
using lld = int64_t;
class S {
public:
tuple<lld, lld, lld> sp(lld n, lld k, lld d1, lld d2) {
lld a = k + d2 + 2 * d1;
if (a % 3 == 0) {
a /= 3;
} else {
return make_tuple(-1, -1, -1);
}
lld b = a - d1;
lld c = k - a - b;
if (a < ... | 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(input());
while t > 0:
t -= 1;
n, k, d1, d2 = map(long, raw_input().split());
n -= k;
flag = 0;
if n-d2-2*d1 >= 0 and (n-d2-2*d1) % 3 == 0 and 2*d2+d1<=k and (k-2*d2-d1)%3==0:
flag = 1;
elif d2>=d1 and n-d1-d2 >= 0 and (n-d1-d2) % 3 == 0 and 2*d2-d1<=k and (k-2*d2+d1) % 3== 0:
flag = 1;
elif d1 >= d2... | 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;
vector<bool> ans;
bool ok(long long n, long long k, long long d1, long long d2) {
if ((k - (d2 + 2 * d1)) >= 0 && (k - (d2 + 2 * d1)) % 3 == 0 &&
(n - (k + d1 + 2 * d2)) >= 0 && (n - (k + d1 + 2 * d2)) % 3 == 0)
return true;
if (k + d1 + d2 >= 0 && (k + d1 + d... | 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>
int t;
long long n, k, d1, d2, td1, td2, x1, x2, x3;
bool solve() {
if (n % 3) return false;
for (int i = -1; i <= 1; ++i)
for (int j = -1; j <= 1; ++j) {
if (i == 0 || j == 0) continue;
d1 = i * td1;
d2 = j * td2;
if ((d1 * 2 + d2 + k) % 3 || (d2 - d1 + k) % 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;
long long n, k;
bool check(long long d1, long long d2) {
long long x, y, z;
if ((2 * d1 + d2 - k) % -3) return false;
x = (2 * d1 + d2 - k) / -3;
z = d1 + d2 + x;
y = k - x - z;
if (x < 0 || y < 0 || z < 0) return false;
if (d1 > 0 && k - 2 * x - z < 0) 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;
int main() {
long long a[5];
int T;
cin >> T;
while (T--) {
long long n, d1, d2, k, t;
scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2);
if (n % 3 != 0) {
printf("no\n");
continue;
}
t = n / 3;
if ((k - d1 + d2) % 3 == 0) {
a... | 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.*;
import java.io.*;
public class a {
public static void main(String[] args) throws IOException
{
input.init(System.in);
PrintWriter out = new PrintWriter(System.out);
int T = input.nextInt();
for(int t = 0; t<T; t++)
{
long n = input.nextLong(), k = input.nextLong(), d1 = i... | 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 com.sun.org.apache.bcel.internal.generic.FieldGen;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Template implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
void init() throws FileNotFoundException {
... | 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 maxi(long long int a, long long int b, long long int c) {
if (a < b) {
return (b > c) ? b : c;
} else {
return (a > c) ? a : c;
}
}
bool cal(long long int a, long long int b, long long int c, long long int k,
long long int n) {
if (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 | #include <bits/stdc++.h>
using namespace std;
long long n, k, x, y, z;
bool work(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 < 0 || y < 0) return false;
long long l = max(max(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 | #include <bits/stdc++.h>
int64_t max(int64_t a, int64_t b) {
if (a < b) return b;
return a;
}
int64_t min(int64_t a, int64_t b) {
if (a < b) return a;
return b;
}
int main() {
int64_t t, i, n, k, d1, d2;
scanf("%" PRId64, &t);
for (i = 0; i < t; ++i) {
scanf("%" PRId64, &n);
scanf("%" PRId64, &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 f(long long t, long long d1, long long d2);
int f(long long t, long long d1, long long d2) {
long long r = t + d2 - d1;
long long m = r / 3;
if ((!(r % 3)) && ((m >= d2)) && (m >= -d1) && (m >= 0)) return 1;
return 0;
}
int main() {
long long n;
long long 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 main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int test;
cin >> test;
while (test--) {
long long int n, k;
cin >> n >> k;
long long int d1, d2;
cin >> d1 >> d2;
vector<long long int> p1 = {d1, -d1};
vector<long long int> 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 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m = sc.nextInt();
for (int i = 0; i < m; i++) {
long n = sc.nextLong();
long k = sc.nextLong();
long d1 = sc.nextLong();
long d2 = sc.nextLong();
if (n%3 != 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 | #!/usr/bin/env python
def read():
n = int(raw_input())
ret = []
for i in range(n):
ret.append(map(int, raw_input().split()))
return ret
def work(vvList):
for (n, k, d1, d2) in vvList:
def judge():
if n % 3 != 0:
print "no"
re... | 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;
long long a[10];
int main() {
ios::sync_with_stdio(false);
int T;
cin >> T;
while (T--) {
cin >> n >> k >> d1 >> d2;
bool flag = 0;
long long a[3];
for (int i = 0; i < 4 && !flag; i++) {
if (i == 1) d1 = -d1;
if (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 |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
public class TaskC {
/**
* @param args
*/
public static void main(String[] args) {
TaskC task = new TaskC();
task.read();
task.write();
}
int 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;
long long _, a, b, t, x, y, n, k;
bool V(long long i, long long j) {
long long u = k - i - j, g = -u / 3;
return !(u % 3 || i < g || 0 < g || j < g ||
n - u - max(i, max(j, 0ll)) * 3 < 0);
}
int main() {
for (cin >> _; _--;)
cin >> n >> k >> a >> b,
... | 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 a, long long b, long long c, long long n, long long k) {
long long g1 = k - a - b - c;
if (g1 < 0) g1 = -g1;
if (g1 % 3) return false;
long long Min = min(min(a, b), c);
if (a + b + c - 3 * Min > k) return false;
long long need = max(max(a, ... | 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;
void solve() {
long long n, k, d1, d2;
scanf("%lld", &n);
;
scanf("%lld", &k);
;
scanf("%lld", &d1);
;
scanf("%lld", &d2);
;
if (n % 3 != 0) {
printf("no\n");
return;
}
int bj = 0;
if ((k - d1 - d2) >= 0 && (k - d1 - d2) % 3 == 0) {
if ... | 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 | def do_solve(n, k, d1, d2):
w1 = 2 * d1 + k + d2
if w1 % 3:
return False
w1 /= 3
w2 = w1 - d1
w3 = w2 - d2
ws = [w1, w2, w3]
#print ws
if all(map(lambda x: x >= 0, ws)) \
and all(map(lambda x: x <= n / 3, ws)):
return True
else:
return False
def ... | 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
def solve(n, k, d1, d2):
d = n - k
# a >= b and c >= b
c1 = (k - d1 + 2 * d2) // 3
a1 = d1 - d2 + c1
b1 = k - a1 - c1
# a >= b and c < b
c2 = (k - d1 - 2 * d2) // 3
a2 = d1 + d2 + c2
b2 = k - a2 - c2
# a < b and c < b
c3 = (k + d1 - 2 * d2) // 3
... | 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 solveFaster(long long n, long long k, long long d1, long long d2) {
if (n % 3 != 0) {
return 0;
}
for (int sign1 = -1; sign1 <= 1; sign1++) {
for (int sign2 = -1; sign2 <= 1; sign2++) {
if (sign1 == 0 || sign2 == 0) {
continue;
}
... | 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 round258;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class C2 {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
for(int T = ni();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 | import java.util.InputMismatchException;
import java.math.BigInteger;
import java.io.*;
/**
* Generated by Contest helper plug-in
* Actual solution is at the bottom
*/
public class Main {
public static void main(String[] args) {
InputReader in = new StreamInputReader(System.in);
PrintWriter out = new PrintWri... | 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;
long long n, k, d1, d2;
for (int i = 0; i < t; i++) {
cin >> n >> k >> d1 >> d2;
if ((n % 3 > 0) || (d1 > k) || (d2 > k)) {
cout << "no" << endl;
continue;
}
if ((((n - k - d1 - d2 - d2) % 3) == 0) && (n - 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;
inline int init() {
int now = 0, ju = 1;
char c;
bool flag = false;
while (1) {
c = getchar();
if (c == '-')
ju = -1;
else if (c >= '0' && c <= '9') {
now = now * 10 + c - '0';
flag = true;
} else if (flag)
return now * ju;
... | 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 _ in xrange(int(raw_input())):
n,k,d1,d2 = [int(c) for c in raw_input().split()]
M,m = max(d1,d2),min(d1,d2)
if n % 3:
print 'no'
else:
r = [(d1+d2,2*M-m),(2*M-m,d1+d2),(2*d1+d2,d1+2*d2),(d1+2*d2,2*d1+d2)]
if any(a <= k and (a-k)%3 == 0 and b <= n-k and (b-n+k)%3 == 0 for a,b in r):
print 'yes'
else:... | 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 | q = input()
while q > 0:
n, k, d1, d2 = map(int, raw_input().split())
if d1 > d2:
d1, d2 = d2, d1
if k - 2 * d1 - d2 >= 0 and (k - 2 * d1 - d2) % 3 == 0 and \
(n - k) - d1 - 2 * d2 >= 0 and ((n - k) - d1 - 2 * d2) % 3 == 0:
print 'yes'
elif k - 2 * d2 - d1 >= 0 and (k - 2 * ... | 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 | read = lambda: map(int, input().split())
f = lambda x, y, a, b: x > a or y > b or (a - x) % 3 or (b - y) % 3
g = lambda x, y, a, b: f(x, y, a, b) and f(x, y, b, a)
t = int(input())
for i in range(t):
n, k, d1, d2 = read()
r = n - k
d = d1 + d2
p = 2 * d2 - d1 if d2 > d1 else 2 * d1 - d2
print('no' i... | 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() {
ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
long long n, k, d1, d2;
cin >> n >> k >> d1 >> d2;
if (n % 3) {
cout << "no\n";
continue;
}
int flag = 0;
long long x1, x2, x3;
if (2 * d1 + d2 + 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;
int cases(long long n, long long k, long long d1, long long d2) {
if (n % 3 != 0) {
return 0;
}
for (int sign1 = -1; sign1 <= 1; sign1++) {
for (int sign2 = -1; sign2 <= 1; sign2++) {
if (sign1 == 0 || sign2 == 0) {
continue;
}
long 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 |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args) throws Exception {
solve();
}
public static void solve() throws IOException {
FastScanner fscan = new FastScanner(System... | 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 |
for t in range(int(input())):
n,k,d1,d2=map(int,input().split())
#d1,d2=max(d11,d22),min(d11,d22)
flag=False
x=(k+(2*d1)+d2)//3
a,b,c=x,x-d1,x-d1-d2
n1=n//3
flag1=True
if n%3!=0 or (abs(n1-a)+abs(n1-b)+abs(n1-c))!=(n-k) or a+b+c!=k or a>n1 or b>n1 or c>n1 or a<0 or b<0 or c<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.util.*;
import java.io.*;
public class PredictOutcomeOfTheGame {
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.out);
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;
bool play(long long x, long long y, long long z, long long rem) {
long long _1 = abs(x - y);
rem -= _1;
x = max(x, y);
y = max(x, y);
long long _2 = abs(x - z);
if (z > x)
rem -= (2 * _2);
else
rem -= _2;
x = max(x, z);
y = max(x, z);
z = max(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 | import java.util. Scanner;
public class Outcome {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int i = 0; i < t; i ++) {
long n = sc.nextLong();
long k = sc.nextLong();
long d1 = sc.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 | import com.sun.prism.shader.Solid_TextureYV12_AlphaTest_Loader;
import java.util.*;
import java.io.*;
public class Main {
public static int solve(long n, long k, long d1, long d2) {
if (n % 3 != 0) {
return 0;
}
for (int ss = -1; ss <= 1; ss++) {
for (int ss2 = -1; s... | 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 n, k, d1, d2;
bool f(long long a, long long b) {
long long c = k - a - b * 2;
if (c < 0 || c % 3) return 0;
return n / 3 >= a + b + c / 3;
}
int main() {
int t;
cin >> t;
for (int i = 1; i <= t; i++) {
cin >> n >> k >> d1 >> d2;
if (n % 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;
long long int check(long long int n, long long int k, long long int d1,
long long int d2) {
long long int b, c, a, w;
w = k - d1 + d2;
if (w % 3 == 0) {
w = w / 3;
b = n / 3;
b -= w;
a = b - d1;
c = b + d2;
n = n - k;
if... | 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.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = ne... | 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.*;
public class C_258 {
public static void main(String[] args) throws IOException {
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(input);
i... | 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 | n=int(raw_input())
for x in range(n):
num = map(int, raw_input().split())
n=num[0]
k=num[1]
d1=num[2]
d2=num[3]
if n%3!=0:
print 'no'
continue
a=(k+2*d1+d2)/3
b=(k-d1+d2)/3
c=(k-d1-2*d2)/3
if ((n/3)-a)>=0 and ((n/3)-b)>=0 and ((n/3)-c)>=0 and a>=0 and b>=0 and c>=0 and (k+2*d1+d2)%3==0 and (k-d1+d2)%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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class C {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for (int t = Integer... | 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 fun1(long long n, long long k, long long d1, long long d2) {
long long a = (2ll * d1 + d2 + k) / 3ll;
long long b = a - d1;
long long c = b - d2;
if (a + b + c != k) return 0;
n -= k;
n -= (a - b);
n -= (a - c);
if (n < 0) return 0;
if (a < 0 || b < 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.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
i... | 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.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author PrateekNischal
*/
public cl... | 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.math.*;
import java.util.*;
public class CODEFORCES {
private InputStream is;
private PrintWriter out;
void solve() {
int t = ni();
while (t-- > 0) {
long n = nl(), k = nl(), d1 = nl(), d2 = nl();
if (n % 3 != 0) {
out.println("no");
continue;
}
boolean u = fal... | 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.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
*/
public class Main {
public static... | 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.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String args[]) throws NumberFormatException,IOException {
Stdin in = new Stdin();
PrintWriter out = new PrintWri... | 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>
#pragma comment(linker, "/stack:225450978")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long Mod = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9,
... | 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;
struct print {
public:
static void lnrev(vector<int> x) {
long long int n = x.size();
for (int i = n - 1; i >= 0; i--) cout << x[i] << " ";
cout << endl;
}
static void ln(vector<long long int> y) {
long long int n = y.size();
for (long long int 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, k, n, d1, d2, md;
bool jg(long long a, long long b, long long c) {
long long s = a + b + c;
if (k < s || (k - s) % 3) return 0;
long long t = n - k - (3 * max(max(a, b), c) - s);
if (t < 0 || t % 3) return 0;
return 1;
}
int main() {
cin >> t;
whi... | 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;
class Graph {
public:
int V;
vector<vector<int> > adj;
Graph(int n) : V(n), adj(n) {}
void add_edge(int u, int v) {
adj[u].push_back(v);
adj[v].push_back(u);
}
};
inline int gcd(int a, int b) {
while (a > 0 && b > 0) {
if (a > b)
a %= b;
e... | 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 isok(long long n, long long k, long long d1, long long d2) {
if (n % 3) return false;
long long win[5], sum = 0, Max, Min;
win[3] = 0;
win[2] = win[3] + d2;
win[1] = win[2] + d1;
sum = win[1] + win[2] + win[3];
Max = max(win[1], max(win[2], win[3]));
Mi... | 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 i, k, j, m, t, n, d1, d2;
scanf("%lld", &t);
while (t--) {
scanf("%lld%lld%lld%lld", &n, &k, &d1, &d2);
if (n % 3 != 0) {
printf("no\n");
continue;
}
n = n - k;
if (k >= 2 * d1 + d2 && (k - d1 - d1 - 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 | def check(n, k, d1, d2):
if (k-d1-d2) % 3 != 0:
return False
y = (k-d1-d2) // 3
x = y+d1
z = y+d2
t = n // 3
if x < 0 or y < 0 or z < 0:
return False
if x > t or y > t or z > t:
return False
return True
t = int(input())
for _ in range(t):
n, k, d1, d2 = map(i... | 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.util.*;
public class Main{
static boolean f(long n,long k,long d1,long d2){
if(n%3!=0)return false;
if(k<d1+d2+d2)return false;
k-=(d1+d2+d2);
if(k%3==0){
long cnt=k/3;
long mxa=cnt+d1+d2;
long temp=n/3;
if(mxa>temp)return false;
return true;
}
return false;
}
public st... | 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 sys
from random import randint
from time import time
t,=map(lambda x:int(x),sys.stdin.readline().strip('\n').split(" "))
for i in xrange(0,t):
n,k,d1,d2=map(lambda x:int(x),sys.stdin.readline().strip('\n').split(" "))
d1,d2=max(d1,d2),min(d1,d2)
if 2*d1+d2<=k and (2*d1+d2)%3==k%3 and (2*d2+d1)<=n-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;
int main() {
int t;
cin >> t;
while (t--) {
long long d1, d2, n, k, a, b, c;
scanf("%lld%lld%lld%lld", &n, &k, &d1, &d2);
int f = 0;
long long kk = n / 3;
double fa = (double)((k + d2) - 2 * d1) / 3;
if (fa >= 0 && fa == (long long)fa) {
... | 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/env python
def read():
n = int(raw_input())
ret = []
for i in range(n):
ret.append(map(int, raw_input().split()))
return ret
def work(vvList):
for (n, k, d1, d2) in vvList:
def judge():
if n % 3 != 0:
print "no"
re... | 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;
long long n, k, d1, d2;
cin >> t;
while (t--) {
cin >> n >> k >> d1 >> d2;
bool answer = false;
if (d1 + d2 <= k && (k - (d1 + d2)) % 3 == 0) {
long long max = d1 > d2 ? d1 : d2;
if ((3 * max - d1 - d2) <= n - 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 dx[] = {1, 1, -1, -1};
int dy[] = {1, -1, -1, 1};
long long int n, k, d1, d2, rem;
bool _solve(long long int w1, long long int w2, long long int w3) {
long long int tar = n / 3;
if (w1 < 0 || w1 > k || w2 < 0 || w2 > k || w3 < 0 || w2 > k) return false;
if (tar >=... | 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 | '''
x1 + x2 + x3 = k
|x1-x2| = d1
|x2-x3| = d2
x1 - x2 = d1
x2 - x3 = d2
2x1 + x3 = k + d1
x1 - x3 = d1 + d2
3x1 = k + 2d1+d2
x1 = (k+2d1+d2)/3
x2 = x1-d1
x3 = x2-d2
x1 - x2 = -d1
x2 - x3 = d2
x1 - x2 = d1
x2 - x3 = -d2
x1 - x2 = -d1
x2 - x3 = -d2
'''
def solve(n, k, d1, d2):
if n % 3 != 0: return False
fo... | 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;
int check(long long a, long long b, long long c, long long k) {
if (a < 0 or b < 0 or c < 0) return false;
if (a + b + c == k) {
long long greater = max(max(a, b), c);
long long rest = n - k;
long long need = (3LL * greater - (a + b + c));
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 fun(long long x1, long long x2, long long x3, long long n) {
if ((n + x1 + x2 + x3) % 3 == 0) {
long long p = (n + x1 + x2 + x3) / 3;
if (p >= max(x1, max(x2, x3))) {
cout << "yes\n";
return 1;
}
}
return 0;
}
long long fp(long long d... | 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(0.0) * 2.0;
const double eps = 1e-12;
const int dir[8][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1},
{1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
long long pow(long long n, long long m, long long mod = 0) {
if (m < 0) return 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 | #include <bits/stdc++.h>
using namespace std;
bool res(long long d1, long long d2, long long n, long long k) {
long long w1, w2, w3;
w1 = (2 * d1 + k + d2) / 3;
w2 = w1 - d1;
w3 = w2 - d2;
long long x = n / 3 - w1, y = n / 3 - w2, z = n / 3 - w3;
if (x >= 0 && y >= 0 && z >= 0 && x + y + z == n - k && w1 >=... | 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 modulus = 1000000007ll;
const int infty = numeric_limits<int>::max();
struct _ {
_() {
ios_base::Init i;
ios_base::sync_with_stdio(0);
cin.tie(0);
}
} _;
int main() {
int t;
cin >> t;
for (int u = 0; u < t; ++u) {
long long n, k, 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 | import java.util.Scanner;
public class PredictGameOutcome {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
long n = scan.nextLong();
for (int i = 0; i < n; i++) {
boolean yes = false;
long g, p, d1, d2;
g = scan.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 n, k, d1, d2;
vector<long long> ans;
bool test(long long a, long long b, long long c) {
if (a < 0 || b < 0 || c < 0 || a + b + c > k) return false;
ans.clear();
ans.push_back(a);
ans.push_back(b);
ans.push_back(c);
sort(ans.begin(), ans.end());
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 | #include <bits/stdc++.h>
using namespace std;
int outcome(long long n, long long k, long long d1, long long d2,
long long d3) {
if (k < d1 + d2 + d3) return 0;
if ((k - d1 - d2 - d3) % 3) return 0;
long long diff = (k - d1 - d2 - d3) / 3;
d1 += diff, d2 += diff, d3 += diff;
if (n % 3) return 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.*;
import java.util.*;
public class Solution {
static Scanner sc=new Scanner(System.in);
static PrintWriter out=new PrintWriter(System.out);
//Main
public static void main(String args[]) {
int test=1;
test=sc.nextInt();
while(test-->0) {
//Focus
long n=sc.nextLong(),k=sc.nextLong(),D1=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;
int main() {
int t;
scanf("%d", &t);
while (t--) {
long long n, k, d1, d2;
scanf("%I64d", &n);
scanf("%I64d", &k);
scanf("%I64d", &d1);
scanf("%I64d", &d2);
if (n % 3 != 0) {
printf("no\n");
continue;
}
n -= k;
if (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;
const int N = (int)2e5 + 3;
bool check(long long n, long long k, long long dt1, long long dt2) {
if (n % 3 != 0) return false;
long long a, b, c;
for (int i = -1; i <= 1; i += 2)
for (int j = -1; j <= 1; j += 2) {
long long d1 = dt1, d2 = dt2;
d1 *= 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 |
import java.util.Scanner;
public class Snippet {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
long n, k, d1, d2;
for (int l = 0; l < t; ++l) {
n = sc.nextLong();
k = sc.nextLong();
d1 = sc.ne... | 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.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
static long n;
static long d1,d2,k;
public static boolean fun()
{
if(n%3!=0)
return false;
for(int i=-1;i<=1;i++)
{
for(int j=-1;j<=1;j++)
{
if(i==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 | import java.util.*;
public class Main {
public static boolean Solved(long n, long k, long d1, long d2) {
if (n % 3 != 0)
return false;
// case1 > >
boolean flag = false;
while (!flag) {
long c = k - d1 - d2 - d2;
if (c < 0 || c % 3 != 0)
break;
c /= 3;
long b = c + d2;
long a = b + d1;
... | 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.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 |
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;
bool ans;
long long n, k, d1, d2, tmp, a, b, c;
scanf("%d", &t);
while (t--) {
scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2);
if (n % 3 != 0) {
printf("no\n");
continue;
}
ans = false;
do {
tmp = k - 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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Codeforces451C
{
public static void main(String[] args)
{
try
{
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(f.re... | 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.util.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
public class Main{
// ArrayList<Integer> lis = new ArrayList<Integer>();
// ArrayList<String> lis = new ArrayList<String>();
// PriorityQueue<P> que ... | 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 Main {
static InputReader in = new InputReader(System.in);
static PrintWriter out = new PrintWriter(System.out);
static int MOD = 1000000007;
static int M = 505;
static int oo = Integer.MAX_VALUE;
static int[] di = {-1, 1, 0, 0};
static int[] dj = {0, 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;
const int INF = 1e+9;
const double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
int main() {
FILE* ci;
FILE* co;
int t = 0;
cin >> t;
long long n, k, d1, d2;
long long A, B, C, pre, h;
for (int i = 0; i < t; i++) {
cin >> n >> 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 main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
long long n, k, d1, d2, x1, x2, x3, sum = 0;
cin >> n >> k >> d1 >> d2;
if ((k - d1 - d2) % 3 == 0) {
x1 = (k - d1 - d2) / 3;
x2 = x1 + d1;
x3 = x1 + d2;
if (x1 >= 0 && x2 ... | 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.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
FastIO io;
long n, k;
boolean check(long a, long b, long c) {
long s = a + b + c;
if (s > k || (k - s) % 3 != 0) {
return false;
}
long d = (k - s) / 3;
a += d;
... | 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.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class B {
static boolean first(long n, long k, long d1, long d2) {
if ((k - d1 - 2 * d2)% 3L != 0L || (k - d1 + d2) % 3L != 0L)
... | 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 | for t in xrange(input()):
n, k, d1, d2 = map(int, raw_input().split())
if n % 3: print "no"
else:
p = 0
for d1 in [-d1,d1]:
for d2 in [-d2,d2]:
x2 = (k-d1+d2)/3
if (k-d1+d2) % 3: continue
if x2 >= 0 and x2 <= k:
x1 = d1 + x2
x3 = x2 - d2
if x1 >= 0 and x1 <= k and x3 >= 0 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 | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
im... | JAVA |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.