-
Notifications
You must be signed in to change notification settings - Fork 21
/
COCONUT.java
79 lines (75 loc) · 1.86 KB
/
COCONUT.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//https://www.codechef.com/JUNE21C/problems/COCONUT
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int t=0;
if(sc.hasNextInt())
t = sc.nextInt();
while(t--!=0){
// int n = sc.nextInt();
long xa = sc.nextLong();
long xb = sc.nextLong();
long Xa = sc.nextLong();
long Xb = sc.nextLong();
System.out.println(Xa/xa + Xb/xb);
}
}
public static ArrayList<Long> sieve(int n)
{
boolean prime[] = new boolean[n+1];
ArrayList<Long>prime1 = new ArrayList<>();
for(int i=0;i<n;i++)
prime[i] = true;
for(int p = 2; p*p <=n; p++)
{
if(prime[p] == true)
{
for(int i = p*p; i <= n; i += p)
prime[i] = false;
}
}
for(int i = 2; i <= n; i++)
{
if(prime[i] == true){
prime1.add((long)i);
}
}
return prime1;
}
public static int[] sievearr(int n)
{
boolean prime[] = new boolean[n+1];
int primex[] = new int[n+1];
for(int i=0;i<n;i++)
prime[i] = true;
for(int p = 2; p*p <=n; p++)
{
if(prime[p] == true)
{
for(int i = p*p; i <= n; i += p)
prime[i] = false;
}
}
for(int i = 2; i <= n; i++)
{
if(prime[i] == true){
primex[i]=i;
}
}
return primex;
}
public static int[] sortdes(int a[]){
Arrays.sort(a);
int des[] = new int[a.length];
int ind=a.length-1;
for(int e:a){
des[ind--]=e;
}
return des;
}
}