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 |
|---|---|---|---|---|---|
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.io.*;
import java.util.*;
import java.math.*;
public class E
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), c = sc.nextInt();
int[] a = new int[n];
int[] b = new int[n];
for(int i = 0; i < n; i++) {
... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long int n, c;
vector<pair<long long int, long long int> > v;
unsigned long long int check(long long int mid) {
unsigned long long int ans = mid, res = 0;
for (long long int i = 0; i < n; i++) {
ans = v[i].first * 1LL * mid;
if (ans / mid != v[i].first) ret... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.io.*;
import java.math.*;
import java.util.*;
public class SpaceVoyage {
private static final long X_MAX = 1010101010101010101L;
private static final long INF = 1234567890987654321L;
public static void solve(FastIO io) {
int N = io.nextInt();
long C = io.nextLong();
Bi... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
int n, c;
int a[10010], b[10010];
long long lan, ran;
long long chk(long long mi) {
long long rem = c;
for (int i = 0; i < n; ++i) {
double tem = (double)a[i] / b[i] * mi;
if (tem - rem >= 1.0) return 1;
rem -= (long long)tem;
}
if (rem > 0) return -1;
return 0;
}
long lon... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int rdi() {
int d;
scanf("%d", &d);
return d;
}
inline char rdc() {
scanf(" ");
return getchar();
}
inline string rds() {
string s;
cin >> s;
return s;
}
inline double rddb() {
double d;
scanf("%lf", &d);
return d;
}
template <class T>
inline bo... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
__int128 a[1000000], b[1000000];
int main() {
long long n, c;
cin >> n >> c;
long long hi1, hi2;
for (__int128 i = 0; i < n; i++) {
cin >> hi1 >> hi2;
a[i] = hi1, b[i] = hi2;
}
__int128 start1 = 1, finish1 = 4000000000000000000, mid1;
do {
mid1 = (... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import sys
def S(x):
global a, c
ans = 0
for i in range(n):
ans += 1 + (a[i][0] * x) // a[i][1]
return ans
n, c = map(int, raw_input().split())
a = []
for i in xrange(n):
a.append(list(map(int, raw_input().split())))
if S(2 ** 100) == c:
print '-1'
sys.exit(0)
L, ... | PYTHON |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
vector<unsigned long long> a(10005), b(10005);
unsigned long long n, c;
unsigned long long isRange(unsigned long long t) {
unsigned long long k = 0;
for (unsigned long long i = 0; i < n; i++) {
k += 1 + t * a[i] / b[i];
}
return k;
}
int main() {
ios_base::syn... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
const int N = 10010;
const long long inf = 1e18;
using namespace std;
int n;
long long a[N], b[N], c;
long long check(long long x) {
long long ret = 0;
if (x == 0) return n;
for (int i = 0; i < n; i++)
if (a[i] > inf / x)
return inf;
else
ret += (a[i] * x / b[i] + 1);
... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 15;
long long a[N], b[N], c;
long long Count(long long x, int n) {
long long ret = 0, temp;
for (int i = 1; i <= n; ++i) {
if (a[i] != 0 && x / b[i] > c / a[i]) return c + 1;
temp = (a[i] * x) / b[i] + 1;
ret += temp;
}
return ret;
}
... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long o = 1e4 + 1;
long long n, m, q, a[o], b[o];
long long qwq(long long x) {
long long s = 0;
for (long long i = 1; i <= n; i++) {
if (1.0 * x * a[i] > b[i] * (m + 100)) return m + 1000;
s += 1 + x * a[i] / b[i];
}
return s;
}
signed main() {
i... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.math.BigInteger;
import java.util.Scanner;
public class Solution {
private static final int N = 10 * 1000 + 13;
static int n;
static BigInteger[] a, b;
static BigInteger c;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
n = in.nextInt();
... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, c;
long long a[10010], b[10010];
int compare(long long x) {
long long sum = 0;
for (int i = (0); i < (n); ++i) {
sum += a[i] * x / b[i];
if (sum > c - n) return 1;
}
return sum < c - n ? -1 : (sum > c - n ? 1 : 0);
}
long long searchLeft(long long l, ... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int rdi() {
int d;
scanf("%d", &d);
return d;
}
inline char rdc() {
scanf(" ");
return getchar();
}
inline string rds() {
string s;
cin >> s;
return s;
}
inline double rddb() {
double d;
scanf("%lf", &d);
return d;
}
template <class T>
inline bo... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.io.*;
import java.math.*;
import java.util.*;
public class SpaceVoyage {
private static final long X_MAX = 1010101010101010101L;
private static final long INF = 1234567890987654321L;
public static void solve(FastIO io) {
int N = io.nextInt();
long C = io.nextLong();
lo... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.math.BigInteger;
import java.util.Scanner;
/**
* @Author Mikhail Linkov
* Date: 21.04.12
*/
public class ProblemE {
private static long getDays(long x, long a, long b) {
BigInteger x1 = BigInteger.valueOf(x);
BigInteger a1 = BigInteger.valueOf(a);
BigInteger b1 = BigIntege... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.io.*;
import java.util.*;
import java.math.*;
public class Presents implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer st;
Random rnd;
long[] a, b;
static long inf = Long.MAX_VALUE / 2;
BigInteger getDays(int n, long x) {
if(x <= 0) ... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long INF = 1e18 + 10;
int a[N], b[N], n, c;
int check(long long x) {
long long second = 0;
for (int i = 0; i < n; i++) {
double cl = 1 + 1.0 * x * a[i] / b[i];
if (cl > c + 1) return 1;
second += 1 + x * a[i] / b[i];
if ... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
const long long INF = 2e18;
int n;
long long a[N], b[N], c;
bool flag = true;
inline int len(long long x) {
int res = 0;
while (x > 1) {
x /= 10;
res++;
}
return res;
}
int check(long long x) {
long long res = 0;
for (int i = 0; i... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
int suit[110000];
int city[110000];
int n, c;
long long max(long long x, long long y) { return x > y ? x : y; }
long long Getdays(long long x) {
long long sum = 0;
for (int i = 1; i <= n; i++) {
if (1. * x * suit[i] > 1LL * city[i] * c + 1LL * city[i] * 100)
return c + 1000LL;
... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 10010;
int a[maxn], b[maxn], c;
int n;
char check(long long p) {
long long res = 0;
for (int i = 1; i <= n; ++i)
if (a[i] != 0 && 1LL * p / b[i] > 1LL * c / a[i])
return 1;
else
res += 1LL * a[i] * p / b[i];
res += n;
if (res > c... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | input=__import__('sys').stdin.readline
def check(x):
tmp=0
for i in range(n):
tmp+=(1 + (lis[i][0]*x)//lis[i][1])
return tmp
def zer(lis):
for i in lis:
if i[0]>0:
return False
return True
n,c = map(int,input().split())
lis=[]
c1=0
for _ in range(n):
a,b = map(... | PYTHON3 |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int rdi() {
int d;
scanf("%d", &d);
return d;
}
inline char rdc() {
scanf(" ");
return getchar();
}
inline string rds() {
string s;
cin >> s;
return s;
}
inline double rddb() {
double d;
scanf("%lf", &d);
return d;
}
template <class T>
inline bo... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int a[10010], b[10010];
int n, m;
int check(long long mid) {
long long res = n;
for (int i = 1; i <= n; ++i) {
if (a[i] != 0 && mid / b[i] > m / a[i]) return 1;
res += mid * a[i] / b[i];
}
if (res > m)
return 1;
else if (res < m)
return -1;
else ... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.io.*;
import java.math.*;
import java.util.*;
public class SpaceVoyage {
private static final long X_MAX = 1010101010101010101L;
private static final long INF = 1234567890987654321L;
public static void solve(FastIO io) {
int N = io.nextInt();
long C = io.nextLong();
Bi... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100 * 100 + 10;
long long a[maxn], b[maxn], c;
int n;
long long fi = 0, se = 1000000000000000000ll;
inline long long valid(long long x) {
long long days = n;
for (int i = 1; i <= n; ++i) {
if (a[i] != 0) {
long long mod1 = a[i] % b[i];
l... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main {
/**
* @param args
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
new Main().run();
}
ArrayList <BigInteger> a = new ArrayList <BigInteger> ();
ArrayList <BigInteger> b... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long Maxn = 2e5 + 7;
const long long Max = 5e6 + 7;
const long long Mod = 1e9 + 7;
const long long Inf = 2e9 + 1e8;
long long p[Max], a[Max], n, c, ans, ans1, mx;
long long check(long long x) {
long long sum = 0;
for (long long i = 1; i <= n; i++) {
long ... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 10;
const long long INF = 6e18;
int n;
long long c, x[MAXN], y[MAXN];
long long get(long long z) {
long long ret = n;
for (int i = 0; ret <= c && i < n; i++) {
long long a = x[i], b = y[i];
if (a == 0) continue;
if (INF / z < a) return... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n;
long long m, lo, hi, a[100005], b[100005], A;
long long doit(long long x) {
long long r = 0;
for (int i = (0); i < (n); i++) {
if (!a[i]) {
r++;
continue;
}
if (x > m * b[i] / a[i] + b[i]) return m + 1;
r += 1 + x * a[i] / b[i];
if... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 20000;
int n, c;
int a[MAXN], b[MAXN];
inline long long check(long long x) {
long long sum = 0;
for (int i = 0; i < n; i++) {
if (1. * x * a[i] > 1LL * b[i] * c + 1LL * b[i] * 100) return c + 1000LL;
sum += 1 + (x * a[i]) / b[i];
}
return su... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int rdi() {
int d;
scanf("%d", &d);
return d;
}
inline char rdc() {
scanf(" ");
return getchar();
}
inline string rds() {
string s;
cin >> s;
return s;
}
inline double rddb() {
double d;
scanf("%lf", &d);
return d;
}
template <class T>
inline bo... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import java.util.Arrays;
public class Main {
static BigInteger[] a=new BigInteger[10005];
static BigInteger[] b=new BigInteger[10005];
static int n;
static void debug(Object... os) {
System.err.println(Arrays.deepToString(os));
}
sta... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | I = lambda: map(int, raw_input().split())
n, c = I()
a = []
b = []
for i in xrange(n):
u, v = I()
a.append(u)
b.append(v)
def count(x):
res = 0
for i in xrange(n):
res += 1
candies = a[i] * x
res += candies / b[i]
return res
# First, we find the least value of x --> s... | PYTHON |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int rdi() {
int d;
scanf("%d", &d);
return d;
}
inline char rdc() {
scanf(" ");
return getchar();
}
inline string rds() {
string s;
cin >> s;
return s;
}
inline double rddb() {
double d;
scanf("%lf", &d);
return d;
}
template <class T>
inline bo... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
const long long high2 = 9223372036854775804;
using namespace std;
int i, n, m, x, y, xa = 0, sum, cnt = 0;
vector<int> a, b;
long long l, r, avg, res1, res2, o, c;
unsigned long long xy;
long long go2(long long z) {
xy = 0;
unsigned long long xold = 0;
long double xtr = 0;
for (i = 0; i... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long ara[100005], tra[100005];
bool ck(long long fr, long long sc) {
if (fr == 0 || sc == 0) return true;
long long x, y, z;
x = fr * sc;
y = x / fr;
if (y == sc)
return true;
else {
return false;
}
}
int main() {
long long n, c, lo, hi, mid, i,... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | def f(x, t):
y = x
while sum((y * a) // b for a, b in t) < c: y += 1000000
while y - x > 1:
z = (x + y) // 2
d = sum((z * a) // b for a, b in t)
if d < c: x = z
else: y = z
return y
n, c = map(int, input().split())
c -= n
t = [tuple(map(int, input().split())) for i i... | PYTHON3 |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
int a[10005], b[10005], n, c, i, flag;
long long two[10005], L, R;
int check(long long x) {
double now = 0;
long long ret = 0;
for (int i = 1; i <= n; i++) {
now += 1. * a[i] * x / b[i];
if (now > c + 1) return c + 1;
ret += (long ... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int rdi() {
int d;
scanf("%d", &d);
return d;
}
inline char rdc() {
scanf(" ");
return getchar();
}
inline string rds() {
string s;
cin >> s;
return s;
}
inline double rddb() {
double d;
scanf("%lf", &d);
return d;
}
template <class T>
inline bo... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double const eps = 1e-10;
int const INF = 100000;
int const MOD = 1;
int const MAX = 1000 * 100 + 5;
int a[MAX];
int b[MAX];
int n;
long long check(long long x, int c) {
long long res = 0;
for (int i = 0; i < n; ++i) {
if (a[i] != 0 && x > ((long long)b[i] * (c - re... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 11111;
long long n, a[N], b[N], c;
inline long long calc(long long x) {
long long result = 0ll;
for (int i = 0; i < n; ++i) result += x * a[i] / b[i];
return result;
}
inline long long lower(long long r, long long cmn) {
long long l = 0ll;
while (r -... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
const long long INF = 1000000007LL * 1000000007LL;
int a[MAXN], b[MAXN];
long long gao(int n, long long d) {
long long l = 1, r = INF;
while (l < r) {
long long m = (l + r) / 2;
long long t = d;
for (int i = 0; t > 0 && i < n; ++i) {... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 20360;
long long a[N], b[N], n, c;
const long long INF = 1LL << 60;
long long gao(long long first) {
long long ans = 0LL;
for (int i = (0); i < (int)(n); i++) ans += (first * a[i] / b[i]);
return ans;
}
int main() {
while (cin >> n >> c) {
c -= n;
... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long o = 1e4 + 1;
long long n, m, q, a[o], b[o];
long long qwq(long long x) {
long long s = 0;
for (long long i = 1; i <= n; i++) {
if (1.0 * x * a[i] > b[i] * (m + 100)) return m + 1000;
s += 1 + x * a[i] / b[i];
}
return s;
}
signed main() {
i... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long a[10005], b[10005];
int n, m;
long long mx = 0;
int deal(long long x) {
long long sum = 0;
for (int i = 0; i < n; i++) {
sum += (1 + a[i] * x / b[i]);
if (sum > m) return 2;
}
if (sum == m) return 1;
if (sum > m) return 2;
return 0;
}
long long... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long oo = 1000000000000000000ll;
int n, c;
long long a[10005], b[10005];
int check(long long x) {
long long sum = 0;
for (int i = 1; i <= n; i++) {
if (a[i] > oo / x) return 1;
long long day = 1 + a[i] * x / b[i];
if (day > c || sum > c - day) ret... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
const double EPS = 1E-9;
const int INF = 2 * (1e+9) + 1;
const int NMAX = 2000;
const int MOD = (1e+9) + 7;
long long n, c;
long long a[100100], b[100200];
long long days(long long v) {
long long res = 0;
for (int i = 0; i < (n); ++i) ... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
const double EPS = 1E-9;
const int INF = 2 * (1e+9) + 1;
const int NMAX = 2000;
const int MOD = (1e+9) + 7;
long long n, c;
long long a[100100], b[100200];
long long days(long long v) {
long long res = 0;
for (int i = 0; i < (n); ++i) ... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, c, a[110000], b[110000], i, j, y, z;
long long l, r, l1, r1, x;
int f(long long y);
int main() {
cin >> n >> c;
x = 1;
for (i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
if (a[i] > 0) x = 0;
}
if (x && (n == c)) {
cout << -1;
return 0;
}
if... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
const long double eps = 1e-9;
const double pi = acos(-1.0);
const long long inf = 1e18;
using namespace std;
int a[11111], b[11111], n, c;
unsigned long long ll1, rr1, cc;
bool check(unsigned long long a, unsigned long long b) {
double l1 = log10(1.0 * a);
double l2 = log10(1.0 * b);
doub... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.util.*;
import java.math.*;
public class Main
{
static public BigInteger F(BigInteger a[],BigInteger b[],int n,BigInteger x)
{
int i;
BigInteger ans,temp;
ans=BigInteger.valueOf(n);
for(i=0;i<n;i++)
{
temp=a[i].multiply(x);
ans=ans.add(... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long inf = 1LL << 60;
int a[10010], b[10010];
int n, c;
int solve(long long x) {
long long sum = n;
for (int i = 0; i < n; i++) {
if (x >= c && a[i] / b[i] >= 1) return 1;
sum += x / b[i] * a[i] + x % b[i] * a[i] / b[i];
if (sum > c) return 1;
}... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int Maxn = 10005;
const long long Inf = 2000000000000000000LL;
int n, c;
int a[Maxn], b[Maxn];
long long l, r;
long long mn = Inf, mx = 0;
long long Mult(long long a, long long b) {
if (a > Inf / b) return Inf;
return a * b;
}
long long Status(long long x) {
lon... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.io.*;
import java.util.*;
public class E1 {
int n, c;
long[] a, b;
public void solve() throws IOException {
n = nextInt();
c = nextInt();
a = new long[n];
b = new long[n];
for (int i = 0; i < n; i++) {
a[i] = nextInt();
b[i] = nextInt();
}
long l, r;
l = 0;
r = (long)(1e18 ... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | def calc(x):
t = 0
for i in range(n):
t += a[i]*x/b[i]+1
return t
#data = open("P5.txt")
n,c = map(int,raw_input().split())
a = []
b = []
ok = False
for _ in range(n):
z,zz = map(int,raw_input().split())
a.append(z)
b.append(zz)
if z != 0: ok = True
if not ok:
if n == c:
... | PYTHON |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long p, n, c, a[10005], b[10005], sum, l, r, m, ansr, ansl;
long long check(const long long x) {
long long ret = 0;
for (int i = 1; i <= n; i++) {
if (ret + x / b[i] > c && a[i] != 0) return c + 1;
ret += x / b[i] * a[i] + (x % b[i]) * a[i] / b[i];
if (... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int N;
long long A[10000], B[10000], C;
long long xC(long long f) {
long long res = 0;
for (int(i) = 0; (i) < (N); (i)++) {
if (double(A[i]) * f > (1e18) || res > C) return 1LL << 61;
res += f * A[i] / B[i] + 1LL;
}
return res;
}
int main() {
scanf("%d%I64... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MaxN = 10004;
long long a[MaxN], b[MaxN], N, C, L, R;
inline int read() {
char ch = getchar();
int x = 0;
bool flag = 0;
for (; ch != '-' && (ch < '0' || ch > '9'); ch = getchar())
;
if (ch == '-') {
flag = 1;
ch = getchar();
}
for (; ch ... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int rdi() {
int d;
scanf("%d", &d);
return d;
}
inline char rdc() {
scanf(" ");
return getchar();
}
inline string rds() {
string s;
cin >> s;
return s;
}
inline double rddb() {
double d;
scanf("%lf", &d);
return d;
}
template <class T>
inline bo... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, c;
int A[10000];
int B[10000];
long long f(long long x) {
long long res = n;
for (int i = 0; i < n; ++i) res += A[i] * x / B[i];
return res;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> c;
if (c < n) return cout << 0 << endl, 0;
... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long N, C;
long long A[20000], B[20000];
bool all_zero = true;
long long mxa = 0, mnb = 2000000000;
long long process(long long P) {
long long re = 0;
for (int Ni = 0; Ni < N; Ni++) {
if ((long double)A[Ni] * P > (long double)C * B[Ni]) return 1e10;
re += A... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long MAX1 = 1000 * 1000 * 1000;
const long long MAX = MAX1 * MAX1;
const int maxn = 11 * 1000;
long long a[maxn], b[maxn];
int c;
bool check(int n) {
int i;
for ((i) = 0; (i) < (n); (i)++)
if (a[i] != 0) return false;
return true;
}
long long f(long lon... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
unsigned long long n, t, l, r, c, x, pokir, pokan, a[20000], b[20000];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> t;
t -= n;
for (unsigned long long i = 1; i <= n; i++) cin >> a[i] >> b[i];
l = 1;
r = 1e18;
while (l <= ... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int rdi() {
int d;
scanf("%d", &d);
return d;
}
inline char rdc() {
scanf(" ");
return getchar();
}
inline string rds() {
string s;
cin >> s;
return s;
}
inline double rddb() {
double d;
scanf("%lf", &d);
return d;
}
template <class T>
inline bo... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 20000;
int n, c;
int a[MAXN], b[MAXN];
inline long long check(long long x) {
long long sum = 0;
for (int i = 0; i < n; i++) {
if (1. * x * a[i] > 1LL * b[i] * c + 1LL * b[i] * 100) return c + 1000LL;
sum += 1 + (x * a[i]) / b[i];
}
return su... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | n,c = map(int,input().split())
from sys import stdin
lst,q,zero = [],0,0
for i in range(n):
a,b = map(int,stdin.readline().split())
lst.append([a,b])
q=max(q,b*c)
if a==0:zero+=1
def cout(x):
res=n
for i,item in enumerate(lst):
y,z=item[0],item[1]
res+=(x*y//z)
return res
fro... | PYTHON3 |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, m, i, c;
long long a[111111], b[111111], be, ma = 0;
long long ok(long long x) {
long long k0 = 0;
for (int i = 0; i < n; i++) {
k0 += (x * a[i]) / b[i] + 1;
if (k0 > c) return c + 1;
}
return k0;
}
int main() {
cin >> n >> c;
for (i = 0; i < n; i... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int rdi() {
int d;
scanf("%d", &d);
return d;
}
inline char rdc() {
scanf(" ");
return getchar();
}
inline string rds() {
string s;
cin >> s;
return s;
}
inline double rddb() {
double d;
scanf("%lf", &d);
return d;
}
template <class T>
inline bo... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double a[10010], b[10010];
int n, m;
int check(long long x) {
long long s = n;
int i;
for (i = 1; i <= n; i++) {
if (a[i] != 0 && x / b[i] > m / a[i]) return 1;
s = s + x * a[i] / b[i];
}
if (s > m)
return 1;
else if (s < m)
return -1;
else if ... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
new Main().run();
}
Scanner in;
PrintWriter out;
void run() {
in = new Scanner(System.in);
out = new PrintWriter(System.out);
... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
const long long high = 9223372036854775807;
using namespace std;
int i, n, m, x, y, xa = 0, sum, cnt = 0;
vector<int> a, b;
long long l, r, avg, res1, res2, o, c;
unsigned long long xy;
long long go2(long long z) {
xy = 0;
unsigned long long xold = 0;
long double xtr = 0;
for (i = 0; i ... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n;
int a[11111], b[11111], c;
inline long long get(long long mid) {
long long ans = n;
for (int i = 0; i < n; ++i) {
ans += mid * a[i] / b[i];
if (ans > c) return ans;
}
return ans;
}
int main() {
scanf("%d%d", &n, &c);
for (int i = 0; i < n; ++i) sc... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct grad {
long long a, b;
};
int n, c;
long long lowerx, upperx;
grad g[10000 + 1];
bool inf = true;
int calc(long long x) {
long long ret = 0;
long long pom;
for (int i = 1; i <= n; i++) {
double kurcina = (1000000000000000000LL * 1.0) / (x * 1.0);
if (... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n;
long long a[10000], b[10000], c;
int main() {
cin >> n >> c;
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
bool f = 1;
for (int i = 0; i < n; i++)
if (a[i]) f = 0;
if (f) {
if (n == c)
puts("-1");
else
puts("0");
return 0;
}... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | r=lambda:map(int,raw_input().split())
n,c=r()
a=[r()for i in range(n)]
def F(x):
l,r=0,1<<60
while l<r-1:
m=l+r>>1
s=0
for i in range(n):
s+=1+a[i][0]*m/a[i][1]
if s<x:
l=m
else:
r=m
return r
z=F(c+1)-F(c)
print [z,-1][z>10**9]
| PYTHON |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline unsigned long long read() {
unsigned long long s = 0;
bool f = 0;
char ch = ' ';
while (!isdigit(ch)) {
f |= (ch == '-');
ch = getchar();
}
while (isdigit(ch)) {
s = (s << 3) + (s << 1) + (ch ^ 48);
ch = getchar();
}
return (f) ? (-s) ... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int rdi() {
int d;
scanf("%d", &d);
return d;
}
inline char rdc() {
scanf(" ");
return getchar();
}
inline string rds() {
string s;
cin >> s;
return s;
}
inline double rddb() {
double d;
scanf("%lf", &d);
return d;
}
template <class T>
inline bo... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.util.*;
import java.math.*;
public class Main
{
public static void main(String args[])
{
BigInteger _2=new BigInteger("2");
BigInteger _0=new BigInteger("0");
BigInteger _1=new BigInteger("1");
Scanner cin=new Scanner(System.in);
int N=10005;
BigInteger A[]=new BigInteger[N];
BigInteger B[]... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long a[10005], b[10005];
long long tinh(long long x, long long n, long long nc) {
long long cnt = 0, i;
for ((i) = (1); (i) <= (n); (i)++) {
cnt += x * a[i] / b[i];
if (cnt > nc) return 1000111000111000111LL;
}
return cnt;
}
void input() {
long long n... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
long long M;
long long n, c;
long long a[100005], b[100005];
using namespace std;
long long check(long long mid) {
long long sum = 0;
for (long long i = 1; i <= n; i++) {
if (a[i] > M / mid) return 1;
long long day = 1 + a[i] * mid / b[i];
if (day > c || sum > c - day) return 1;... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | def check(x):
global a, b, n
cnt = 0
for i in range(n):
tmp = a[i] * x
tmp /= b[i]
tmp += 1
cnt += tmp
return cnt
while True:
global n
try: n, c = raw_input().split()
except: break
n, c = int(n), int(c)
global a, b
a, b = [0 for i in range(n)... | PYTHON |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class ab5 {
public static void debug(Object... obs)
{
System.out.println(Arrays.deepToString(obs));
}
public... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class E {
BufferedReader in;
StringTokenizer st;
PrintWriter out;
String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(in.readLine());
return st.nextToken();
}
int nextInt() throws... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n;
long long c;
long long a[100005], b[100005];
int main() {
while (scanf("%d%I64d", &n, &c) == 2) {
long long R = 1LL << 60;
c -= n;
int inf = 1;
for (int i = 0; i < n; i++) {
scanf("%I64d%I64d", &a[i], &b[i]);
if (a[i]) {
inf = 0;... | CPP |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | 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 {
try {
in = new BufferedReader(new FileReader... | JAVA |
177_E2. Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.
The Smart Beaver is going to bring som... | 2 | 11 | import java.math.BigInteger;
import java.util.Scanner;
public class Main {
private int n;
private BigInteger[] a;
private BigInteger[] b;
private long c;
private BigInteger cc(BigInteger mid) {
BigInteger r = BigInteger.valueOf(0);
for (int i = 0; i < n; i++) {
r = r.a... | JAVA |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int fib[1000];
inline int sqr(int x) { return x * x; }
int main() {
int x1, y1, r1, R1;
int x2, y2, r2, R2;
scanf("%d%d%d%d", &x1, &y1, &r1, &R1);
scanf("%d%d%d%d", &x2, &y2, &r2, &R2);
double d = sqr(x1 - x2) + sqr(y1 - y2);
int ret = 0;
{
if (sqr(r1 + R2... | CPP |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int ok(long double d, long double r, long double r1, long double R1) {
if (d + r <= r1) return 1;
if (d >= r + R1) return 1;
if (d + R1 <= r) return 1;
return 0;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long double x1, ... | CPP |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long dist;
inline bool check(int r1, int r2, int R2) {
if (dist < ((r1 + R2) * (r1 + R2))) {
if (dist <= abs((r1 - R2) * (r1 - R2)) && (R2 >= r1)) {
if (dist <= abs((r1 - r2) * (r1 - r2)) && (r1 >= r2)) {
return false;
} else {
if (dis... | CPP |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 46;
struct node {
double x, y;
double r1, r2;
double o;
} C[2];
struct circle {
double o, r1, r2;
} c[2];
const double eps = 1e-6;
bool ok(double r, double x1, double x2) {
if (r <= x1 || r >= x2)
return true;
else
return false;
}
bool o... | CPP |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | #include <bits/stdc++.h>
struct circle {
int x, y, r;
};
circle ci[4];
bool inter(circle &a, circle &b) {
int d = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
int t = (a.r + b.r) * (a.r + b.r);
if (t <= d) return 0;
t = (a.r - b.r) * (a.r - b.r);
if (t >= d) return 0;
return 1;
}
bool inside(cir... | CPP |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int Cross(int x1, int y1, int r1, int x2, int y2, int r2) {
double dx = x2 - x1;
double dy = y2 - y1;
double dr = sqrt(dx * dx + dy * dy);
if (dr >= r1 + r2) {
return -1;
} else {
if (r1 >= dr + r2) {
return 1;
} else if (r2 >= dr + r1) {
r... | CPP |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | import java.util.*;
public class Olympics{
public static double dist(int a, int b){
return Math.sqrt(a*a + b*b);
}
public static boolean intersect(int rd, int[] p, int [] q, int r, int R){
if( dist(p[0]-q[0], p[1]-q[1]) >= rd + R ){
// System.out.println("A");
return true;
}
if( dist(p[0]-q[0], p[1]-... | JAVA |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
void fast_in_out() {
std::ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
}
int dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
int dy[] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
int lx[] = {2, 2, -1, 1, -2, -2, -1, 1};
int ly[] = {-1, 1, 2, 2, 1, -1, -2, -2};
const lo... | CPP |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int inf = (int)1e9;
const double inf1 = 1e-9;
int length(int x1, int x2, int y1, int y2) {
return ((x1 - x2) * (x1 - x2) + ((y1 - y2) * (y1 - y2)));
}
bool check(int x1, int y1, int r1, int x2, int y2, int r2, int R2) {
int d = length... | CPP |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | #include <bits/stdc++.h>
const int C = 100001;
struct seg {
double x1, y1, x2, y2;
};
double len(seg a) {
return (a.x1 - a.x2) * (a.x1 - a.x2) + (a.y1 - a.y2) * (a.y1 - a.y2);
}
int main() {
double ax, ay, ar1, ar2, bx, by, br1, br2, k;
int wynn = 0;
seg f, g;
scanf("%lf %lf %lf %lf", &ax, &ay, &ar1, &ar2);... | CPP |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
public class Solution{
public static void mai... | JAVA |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int OO = 1e9;
const double EPS = 1e-9;
bool f(int c_x, int c_y, int c_r, int r_x, int r_y, int r_r, int r_R) {
double dist = sqrt((c_x - r_x) * (c_x - r_x) + (c_y - r_y) * (c_y - r_y));
return (dist >= c_r + r_R) || (dist + c_r <= r_r) || (dist + r_R <= c_r);
}
in... | CPP |
199_B. Special Olympics | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.
Let us remind you that a ring is a region located between two... | 2 | 8 | import java.util.*;
import static java.lang.Math.*;
public class ProblemB {
double EPSILON = 0.000001;
void run() {
Scanner sc = new Scanner(System.in);
int x1 = sc.nextInt();
int y1 = sc.nextInt();
int r1 = sc.nextInt();
int R1 = sc.nextInt();
int x2 = sc.nextInt();
int y2 = sc.nextInt();
in... | JAVA |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.