exec_outcome stringclasses 1 value | code_uid stringlengths 32 32 | file_name stringclasses 111 values | prob_desc_created_at stringlengths 10 10 | prob_desc_description stringlengths 63 3.8k | prob_desc_memory_limit stringclasses 18 values | source_code stringlengths 117 65.5k | lang_cluster stringclasses 1 value | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_time_limit stringclasses 27 values | prob_desc_sample_outputs stringlengths 2 796 | prob_desc_notes stringlengths 4 3k ⌀ | lang stringclasses 5 values | prob_desc_input_from stringclasses 3 values | tags listlengths 0 11 | src_uid stringlengths 32 32 | prob_desc_input_spec stringlengths 28 2.37k ⌀ | difficulty int64 -1 3.5k ⌀ | prob_desc_output_spec stringlengths 17 1.47k ⌀ | prob_desc_output_to stringclasses 3 values | hidden_unit_tests stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PASSED | cdbac0321053d6a4f131455a6c63323c | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.*;
import java.io.*;
public class CFsolve {
public static void main(String[] args) {
FastScanner input = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int t = input.nextInt();
while(t-- > 0){
int h = input.nextInt();
int b = input.nextInt();
int total = h*b;
int answer = total/3;
if(total%3 != 0)
answer += 1;
out.println(answer);
}
out.close();
}
static int LCM(int a, int b){
return a/gcd(a,b) * b;
}
static long LCM(long a, long b){
return (a/gcd(a,b) * b);
}
static int gcd(int a,int b){
while(b>0){
a%=b;
a=a^b;
b=a^b;
a=a^b;
}
return a;
}
static long gcd(long a,long b){
while(b>0){
a%=b;
a=a^b;
b=a^b;
a=a^b;
}
return a;
}
static void swap(int a, int b){
a = a^b;
b = a^b;
a = a^b;
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
byte nextByte(){return Byte.parseByte(next());}
long nextLong() {
return Long.parseLong(next());
}
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | fbf5d97c290873f82d2710a413382d56 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.*;
import java.io.*;
public class CFsolve {
public static void main(String[] args) {
FastScanner input = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int t = input.nextInt();
while(t-- > 0){
int h = input.nextInt();
int b = input.nextInt();
int total = h*b;
int answer = total/3;
int mod = total%3;
if(mod != 0)
answer += 1;
//
// if(mod == 1){
// answer += 1;//answer += (-1) + 2;
// }
// else if(mod == 2){
// answer += 1;
// }
out.println(answer);
}
out.close();
}
static int LCM(int a, int b){
return a/gcd(a,b) * b;
}
static long LCM(long a, long b){
return (a/gcd(a,b) * b);
}
static int gcd(int a,int b){
while(b>0){
a%=b;
a=a^b;
b=a^b;
a=a^b;
}
return a;
}
static long gcd(long a,long b){
while(b>0){
a%=b;
a=a^b;
b=a^b;
a=a^b;
}
return a;
}
static void swap(int a, int b){
a = a^b;
b = a^b;
a = a^b;
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
byte nextByte(){return Byte.parseByte(next());}
long nextLong() {
return Long.parseLong(next());
}
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 424735241b0a44cd4f6931ab1cc207a4 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.Scanner;
public class B_Coloring_Rectangles
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0)
{
int n = sc.nextInt();
int m=sc.nextInt();
int count=0;
int number_in_1_row = m/3;
count+=number_in_1_row*n;
int number_of_columns = m%3;
int number_of_rows = n%3;
count+=n/3 * number_of_columns;
if(number_of_columns==0)
{
System.out.println(count);
continue;
}
if(number_of_rows*number_of_columns==2)
{
count+=1;
}
else
if(number_of_rows*number_of_columns==4)
{
count+=2;
}
else if(number_of_columns*number_of_rows==1)
count++;
System.out.println(count);
}
}
} | Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 52b0144f0b20327a0c302b89228922f3 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.*;
public class Main{
public static void main(String ar[]){
Scanner scan=new Scanner(System.in);
int T=scan.nextInt();
for(int i=0;i<T;i++){
int u=scan.nextInt();
int v=scan.nextInt();
if((u*v)%3==0){
int ans=(v*u)/3;
System.out.println(ans);
}
else System.out.println((v*u)/3+1);
}
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 5eceba5178212c8fde6928584a538e8d | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int T=sc.nextInt();
for (int i=0;i<T;i++){
int n=sc.nextInt();
int m=sc.nextInt();
System.out.println((m*n+2)/3);
}
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 7221004b94f92b98ba943565439557f8 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.*;
import java.io.*;
public class B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = sc.nextInt();
for (; t > 0; t--) {
long n = sc.nextLong(); long m = sc.nextLong();
long ans = Long.MAX_VALUE;
out.println(Math.min(calc(n, m), calc(m, n)));
}
out.close();
sc.close();
}
private static long calc(long n, long m) {
long ln = n % 3;
return m * (n / 3) + ln * (m / 3 + (m % 3 == 0 ? 0 : 1));
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 1ab90a031c9acb37aee48087be2bfc6f | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int tc = 0; tc < t; ++tc) {
int n = sc.nextInt();
int m = sc.nextInt();
System.out.println(solve(n, m));
}
sc.close();
}
static int solve(int n, int m) {
return (n * m + 2) / 3;
}
} | Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | e164f8033d3daa311e9a14d4113cc514 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.Scanner;
public class B1584 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int T = in.nextInt();
for (int t=0; t<T; t++) {
int R = in.nextInt();
int C = in.nextInt();
int squares = R*C;
int answer = (squares+2)/3;
System.out.println(answer);
}
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | f02f210d95ba62cb9c54813e0e6bc398 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes |
import java.io.*;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.StringTokenizer;
public class Main
{
public static void main(String[] args)
{
int t=in.nextInt();
while(t-->0)
{
long n=in.nextLong();
long m=in.nextLong();
//以三个为一分,补
System.out.println((n*m+2)/3);
}
}
// ==== IO ==== //
static InputStream inputStream = System.in;
static InputReader in = new InputReader(inputStream);
static PrintWriter out = new PrintWriter(System.out);
static class InputReader
{
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream)
{
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next()
{
while (tokenizer == null || !tokenizer.hasMoreTokens())
{
try
{
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e)
{
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
boolean hasNext()
{
while (tokenizer == null || !tokenizer.hasMoreTokens())
{
try
{
tokenizer = new StringTokenizer(reader.readLine());
} catch (Exception e)
{
return false;
// TODO: handle exception
}
}
return true;
}
public String nextLine()
{
String str = null;
try
{
str = reader.readLine();
} catch (IOException e)
{
e.printStackTrace();
}
return str;
}
public int nextInt()
{
return Integer.parseInt(next());
}
public long nextLong()
{
return Long.parseLong(next());
}
public Double nextDouble()
{
return Double.parseDouble(next());
}
public BigInteger nextBigInteger()
{
return new BigInteger(next());
}
public BigDecimal nextBigDecimal()
{
return new BigDecimal(next());
}
}
// ==== IO ==== //
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | f6fcd353a9913d441b784e2e043955ca | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
public class B_Coloring_Rectangles {
private static FastScaner in;
private static PrintWriter out;
private static String YES = "YES";
private static String NO = "NO";
private static void solve() throws IOException{
long n = in.nextInt(), m = in.nextInt();
n *= m;
if(n % 3 == 0) System.out.println(n / 3);
else System.out.println((n / 3)+1);
}
public static void main(String[] args) throws IOException{
in = new FastScaner();
out = new PrintWriter(new OutputStreamWriter(System.out));
int T = in.nextInt();
while(T --> 0){
solve();
}
out.flush();
in.close();
out.close();
}
private static final Random random = new Random();
private static final int M = 1_000_000_007;
//Taken From "Second Thread"
private static void ruffleSort(int[] a){
int n = a.length;//shuffles, then sort;
for(int i=0; i<n; i++){
int oi = random.nextInt(n), temp = a[oi];
a[oi] = a[i]; a[i] = temp;
}
sort(a);
}
private static void longRuffleSort(long[] a){
int n = a.length;//shuffles, then sort;
for(int i=0; i<n; i++){
int oi = random.nextInt(n), temp = (int) a[oi];
a[oi] = a[i]; a[i] = temp;
}
longSort(a);
}
private static void sort(int[] a){
ArrayList<Integer> l = new ArrayList<>();
for(int i:a) l.add(i);
Collections.sort(l);
for(int i=0;i<a.length;i++)a[i] = l.get(i);
}
private static void longSort(long[] a){
ArrayList<Long> l = new ArrayList<>();
for(long i:a) l.add(i);
Collections.sort(l);
for(long i=0;i<a.length;i++)a[(int) i] = l.get((int) i);
}
private static long add(long a, long b){
return (a + b) % M;
}
private static int gcd(int a, int b){
if(a == 0 || b == 0){
return 0;
}
while(b != 0){
int temp;
temp = a % b;
a = b;
b = temp;
}
return a;
}
private static long gcd(long a, long b){
if(a == 0 || b == 0){
return 0;
}
while(b != 0){
long temp;
temp = a % b;
a = b;
b = temp;
}
return a;
}
private static int lowestCommonMultiple(int a, int b){
return (a / gcd(a, b) * b);
}
private static int log2(int n){
int result = (int) (Math.log(n) / Math.log(2));
return result;
}
private static long lcm(long a, long b){
return (a / gcd((int) a, (int) b) * b);
}
private static int[][] prefixsum( int n , int m , int arr[][] ){
int prefixsum[][] = new int[n+1][m+1];
for( int i = 1 ;i <= n ;i++) {
for( int j = 1 ; j<= m ; j++) {
int toadd = 0;
if( arr[i-1][j-1] == 1) {
toadd = 1;
}
prefixsum[i][j] = toadd + prefixsum[i][j-1] + prefixsum[i-1][j] - prefixsum[i-1][j-1];
}
}
return prefixsum;
}
private static class FastScaner{
private static final int BUFFER_SIZE = 1 << 16;
private final DataInputStream din;
private final byte[] buffer;
private int bufferPointer, bytesRead;
FastScaner() {//Constructor;
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException {//To take user input for String values;
final byte[] buf = new byte[1024]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n') {
break;
}
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
public int nextSign() throws IOException {//For taking the signs like plus or minus ...
byte c = read();
while ('+' != c && '-' != c) {
c = read();
}
return '+' == c ? 0 : 1;
}
private static boolean isSpaceChar(int c) {
return !(c >= 33 && c <= 126);
}
public int skip() throws IOException {
int b;
// noinspection ALL
while ((b = read()) != -1 && isSpaceChar(b)) {
;
}
return b;
}
public char nc() throws IOException {
return (char) skip();
}
public String next() throws IOException {
int b = skip();
final StringBuilder sb = new StringBuilder();
while (!isSpaceChar(b)) { // when nextLine, (isSpaceChar(b) && b != ' ')
sb.appendCodePoint(b);
b = read();
}
return sb.toString();
}
public int nextInt() throws IOException {
int ret = 0;
byte c = read();
while (c <= ' ') {
c = read();
}
final boolean neg = c == '-';
if (neg) {
c = read();
}
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg) {
return -ret;
}
return ret;
}
public long nextLong() throws IOException {
long ret = 0;
byte c = read();
while (c <= ' ') {
c = read();
}
final boolean neg = c == '-';
if (neg) {
c = read();
}
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (neg) {
return -ret;
}
return ret;
}
public double nextDouble() throws IOException {
double ret = 0, div = 1;
byte c = read();
while (c <= ' ') {
c = read();
}
final boolean neg = c == '-';
if (neg) {
c = read();
}
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg) {
return -ret;
}
return ret;
}
private void fillBuffer() throws IOException {
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1) {
buffer[0] = -1;
}
}
private byte read() throws IOException {
if (bufferPointer == bytesRead) {
fillBuffer();
}
return buffer[bufferPointer++];
}
public void close() throws IOException {
din.close();
}
}
} | Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 2d5cc5a6e057051b5bae5667e2032379 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
for (int t = 0; t < tc; t++) {
int n = sc.nextInt();
int m = sc.nextInt();
int ans = (n * m);
if (ans % 3 == 0) {
System.out.println(ans / 3);
} else {
System.out.println((ans / 3) + 1);
}
}
sc.close();
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | f8a51a040c304552d0db69f9bc240059 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | /**
* B_Coloring_Rectangles
*/
import java.io.*;
import java.util.*;
public class B_Coloring_Rectangles {
public static void main(String[] args) {
MyScanner s = new MyScanner();
int t = s.nextInt();
for(int f = 0;f<t;f++)
{
int n = s.nextInt();
int m = s.nextInt();
int ans = (n*m)/3;
if((n*m)%3!=0)
{
ans+=1;
}
System.out.println(ans);
}
}
}
class MyScanner {
BufferedReader br; StringTokenizer st;
public MyScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine(){
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
} | Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 2b168522ba6191d9949f57d61cff21ac | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | /**
* B_Coloring_Rectangles
*/
import java.io.*;
import java.util.*;
public class B_Coloring_Rectangles {
public static void main(String[] args) {
MyScanner s = new MyScanner();
int t = s.nextInt();
for(int f = 0;f<t;f++)
{
int n = s.nextInt();
int m = s.nextInt();
int ans = (n*m)/3;
if((n*m)%3!=0)
{
ans+=1;
}
System.out.println(ans);
}
}
}
class MyScanner {
BufferedReader br; StringTokenizer st;
public MyScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine(){
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
} | Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 11e7b85811913b251c85bd0bf00e340a | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.*;
import java.io.*;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.*;
import static java.lang.System.out ;
public class CP0007 {
public static void main(String args[])throws Exception{
PrintWriter pw = new PrintWriter(out);
FastReader sc = new FastReader();
Reader s = new Reader();
int test;
try{
test = sc.nextInt();
}
catch(Exception E){
return;
}
while(test-- > 0){
//Code
long a = sc.nextInt() * sc.nextInt() ;
out.println((long)(Math.ceil(1.0* a/3)));
}
pw.close();
}
/*
Note :
Try using sorting , when approach is of O(N^2)
As sorting takes : O( N Log N )
*/
public static String reverseString(String str){
StringBuilder input1 = new StringBuilder();
// append a string into StringBuilder input1
input1.append(str);
// reverse StringBuilder input1
input1.reverse();
return input1+"";
}
public static void sort(int[] arr){
//because Arrays.sort() uses quick sort , Worst Complexity : o(N^2)
ArrayList <Integer> ls = new ArrayList<>();
for(int x:arr){
ls.add(x);
}
Collections.sort(ls);
//Collections.sort(arrayList) : Uses Merge Sort : Complexity O(NlogN)
for(int i = 0 ; i < arr.length ; i++){
arr[i] = ls.get(i);
}
}
public static long gcd(long a , long b){
if(a>b){
a = (a+b) - (a = b);
}
if(a == 0L){
return b;
}
return gcd(b%a ,a);
}
public static boolean isPrime(long n){
if(n < 2){
return false;
}
if(n == 2 || n == 3){
return true;
}
if(n % 2 == 0 || n % 3 == 0){
return false;
}
long sq = (long)Math.sqrt(n) + 1;
for(long i = 5L; i <=sq ; i=i+6){
if(n % i == 0 || n % (i+2) == 0){
return false;
}
}
return true;
}
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader()
{
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public Reader(String file_name) throws IOException
{
din = new DataInputStream(
new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException
{
byte[] buf = new byte[64]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n') {
if (cnt != 0) {
break;
}
else {
continue;
}
}
buf[cnt++] = (byte)c;
}
return new String(buf, 0, cnt);
}
public int nextInt() throws IOException
{
int ret = 0;
byte c = read();
while (c <= ' ') {
c = read();
}
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long nextLong() throws IOException
{
long ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double nextDouble() throws IOException
{
double ret = 0, div = 1;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg)
return -ret;
return ret;
}
private void fillBuffer() throws IOException
{
bytesRead = din.read(buffer, bufferPointer = 0,
BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read() throws IOException
{
if (bufferPointer == bytesRead)
fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException
{
if (din == null)
return;
din.close();
}
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while(st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch(IOException e){
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 0a310ba293899c72cc494ed617a0e3e4 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes |
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.sql.Time;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class Practice1 {
public static void main (String[] args) {
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
// out.print();
//out.println();
FastReader sc=new FastReader();
int t=sc.nextInt();
while(t-->0) {
long n=sc.nextLong();
long m=sc.nextLong();
long val=n*m;
if(val==2||val==3) {
out.println(1);
}else if(val==4) {
out.println(2);
}else {
if(val%3==0) {
out.println(val/3);
}else{
out.println((val)/3+1);
}
}
}
out.close();
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 731a7b37591c40d934ea38678d637236 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
public class CodeForces {
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
static void sort (int[]a){
ArrayList<Integer> b = new ArrayList<>();
for(int i:a)b.add(i);
Collections.sort(b);
Collections.reverse(b);
for(int i=0;i<b.size();i++){
a[i]=b.get(i);
}
}
public static void main(String[] args) throws IOException {
FastScanner fs = new FastScanner();
StringBuilder sb = new StringBuilder();
int t = fs.nextInt();
for (int i=0;i<t;i++){
int n = fs.nextInt();
int m = fs.nextInt();
int multi= n*m;
int ans = multi/3;
int remain=multi%3;
if(remain!=0){
ans++;
}
sb.append(ans+"\n");
}
System.out.println(sb.toString());
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 44bd94ea10f31d545121c54ab2d242d4 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.io.*;
import java.util.*;
public class cf {
public static void main(String[] args){
FastScanner sc = new FastScanner();
int z = sc.nextInt();
//int z=1;
while(z-- > 0){
//boolean check=true;
int a=sc.nextInt();
int b=sc.nextInt();
/*int a[]=new int[n];
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
}*/
int ar=a*b;
int x=ar/3;
if(ar%3==0){
System.out.println(x);
}
else{
System.out.println(x+1);
}
}
}
}
/////////////////////////////////////////////////////////////
//BINARY SEARCH
/*Arrays.binarySearch(arr,key);
if key--> present
return index
else
return -(index where it would be inserted)-1*/
//////////////////////////////////////////////////////////////
/* VALUE JUST GREATER THAN X
find_min(int[]arr,int x){
int l=-1;
int r=arr.length;
while(r>l+1){
int mid=(l+r)/2;
if(arr[mid]<x){
l=mid;
}
else{
r=mid;
}
}
return r;
}
VALUE JUST SMALLER THAN X
find_max(int[]arr,int x){
int l=-1;
int r=arr.length;
while(r>l+1){
int mid=(l+r)/2;
if(arr[mid]<=x){
l=mid;
}
else{
r=mid;
}
}
return l;
}
*/
//////////////////////////////////////////////////////////////
// LCM AND GCD
/*
public static int gcd(int a,int b){
if(b == 0){
return a;
}
return gcd(b,a%b);
}
public static int lcm(int a,int b){
return (a / gcd(a, b)) * b;
}*/
///////////////////////////////////////////////////////////////////////////////////
//Iterator
/*Iterator iterator = object.iterator();
while (iterator.hasNext()) {
System.out.print(iterator.next() + " ");
}*/
///////////////////////////////////////////////////////////////////////////////////
class FastScanner
{
//I don't understand how this works lmao
private int BS = 1 << 16;
private char NC = (char) 0;
private byte[] buf = new byte[BS];
private int bId = 0, size = 0;
private char c = NC;
private double cnt = 1;
private BufferedInputStream in;
public FastScanner() {
in = new BufferedInputStream(System.in, BS);
}
public FastScanner(String s) {
try {
in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
} catch (Exception e) {
in = new BufferedInputStream(System.in, BS);
}
}
public char getChar() {
while (bId == size) {
try {
size = in.read(buf);
} catch (Exception e) {
return NC;
}
if (size == -1) return NC;
bId = 0;
}
return (char) buf[bId++];
}
public int nextInt() {
return (int) nextLong();
}
public int[] nextInts(int N) {
int[] res = new int[N];
for (int i = 0; i < N; i++) {
res[i] = (int) nextLong();
}
return res;
}
public long[] nextLongs(int N) {
long[] res = new long[N];
for (int i = 0; i < N; i++) {
res[i] = nextLong();
}
return res;
}
public long nextLong() {
cnt = 1;
boolean neg = false;
if (c == NC) c = getChar();
for (; (c < '0' || c > '9'); c = getChar()) {
if (c == '-') neg = true;
}
long res = 0;
for (; c >= '0' && c <= '9'; c = getChar()) {
res = (res << 3) + (res << 1) + c - '0';
cnt *= 10;
}
return neg ? -res : res;
}
public double nextDouble() {
double cur = nextLong();
return c != '.' ? cur : cur + nextLong() / cnt;
}
public double[] nextDoubles(int N) {
double[] res = new double[N];
for (int i = 0; i < N; i++) {
res[i] = nextDouble();
}
return res;
}
public String next() {
StringBuilder res = new StringBuilder();
while (c <= 32) c = getChar();
while (c > 32) {
res.append(c);
c = getChar();
}
return res.toString();
}
public String nextLine() {
StringBuilder res = new StringBuilder();
while (c <= 32) c = getChar();
while (c != '\n') {
res.append(c);
c = getChar();
}
return res.toString();
}
public boolean hasNext() {
if (c > 32) return true;
while (true) {
c = getChar();
if (c == NC) return false;
else if (c > 32) return true;
}
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 2bb98322d53bca61171cd36140f36381 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
public class codeforces1584B {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int numberCases = Integer.parseInt(br.readLine());
for (int rep=1; rep<=numberCases;rep++)
{
StringTokenizer st = new StringTokenizer(br.readLine());
int length = Integer.parseInt(st.nextToken());
int width = Integer.parseInt(st.nextToken());
//System.out.println(length);
//System.out.println(width);
int painted = 0;
if (length*width==1)
{
System.out.println(0);
continue;
}
if ((length*width)%3==0)
{
painted=length*width/3;
System.out.println(painted);
}
if ((length*width)%3==1 || (length*width)%3==2)
{
painted=(length*width/3)+1;
System.out.println(painted);
}
}
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 17013c58d570d2332f22f4726e05db0c | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.*;
import java.io.*;
//import static com.sun.tools.javac.jvm.ByteCodes.swap;
// ?)(?
public class fastTemp {
static FastScanner fs = null;
public static void main(String[] args) {
fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int t = fs.nextInt();
while (t-- > 0) {
int n = fs.nextInt();
int m = fs.nextInt();
long s = n*m;
if(s%3==0){
out.println(s/3);
}else if(s%3==1){
out.println((s/3)+1);
}else{
out.println((s/3)+1);
}
}
out.close();
}
static class Pair implements Comparable<Pair>{
int x;
int y;
Pair(int x,int y){
this.x = x;
this.y = y;
}
public int compareTo(Pair o){
int z = o.x + o.y;
int l = x+y;
return l-z;
}
}
public static boolean contains(String s,String s1){
boolean found = false;
for(int i=0;i<s.length();i++){
for(int j = i+1;j<s.length();j++){
String ss = s.substring(i,j);
if(ss.equals(s1)){
found = true;
}
}
}
return found;
}
// Math.ceil(k/n) == (k+n-1)/n
//----------------------graph--------------------------------------------------
/* int vtces = fs.nextInt();
ArrayList<Integer> graph[] = new ArrayList[vtces];
for (int v = 0; v < vtces; v++) {
graph[v] = new ArrayList<>();
}
int edge = fs.nextInt();
for (int i = 0; i < edge; i++) {
int u = fs.nextInt();
int v = fs.nextInt();
graph[u].add(v);
graph[v].add(u);
}
*/
//----------------------graph--------------------------------------------------
public static boolean palindrome(String s){
if(s.length()==1){
return true;
}
int i = 0;
int j = s.length()-1;
while(i!=j && i<s.length() && j>=0){
if(s.charAt(i)==s.charAt(j)){
i++;
j--;
}else{
return false;
}
}
return true;
}
public static class String1 implements Comparable<String1>{
String str;
int id;
String1(String str , int id){
this.str = str;
this.id = id;
}
public int compareTo(String1 o){
int i=0;
while(i<str.length() && str.charAt(i)==o.str.charAt(i)){
i++;
}
if(i<str.length()){
if(i%2==1){
return o.str.compareTo(str); // descending order
}else{
return str.compareTo(o.str); // ascending order
}
}
return str.compareTo(o.str);
}
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
// ------------------------------------------swap----------------------------------------------------------------------
static void swap(int arr[],int i,int j)
{
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
//-------------------------------------------seiveOfEratosthenes----------------------------------------------------
static boolean prime[];
static void sieveOfEratosthenes(int n)
{
// Create a boolean array
// "prime[0..n]" and
// initialize all entries
// it as true. A value in
// prime[i] will finally be
// false if i is Not a
// prime, else true.
prime= new boolean[n + 1];
for (int i = 0; i <= n; i++)
prime[i] = true;
for (int p = 2; p * p <= n; p++)
{
// If prime[p] is not changed, then it is a
// prime
if (prime[p] == true)
{
// Update all multiples of p
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
// Print all prime numbers
// for (int i = 2; i <= n; i++)
// {
// if (prime[i] == true)
// System.out.print(i + " ");
// }
}
// ---------------------------------------- power------------------------------------------------------------------
public static long power(int a , int b) {
if (b == 0) {
return 1;
} else if (b == 1) {
return a;
} else {
long R = power(a, b / 2);
if (b % 2 != 0) {
return (((power(a, b / 2))) * a * ((power(a, b / 2))));
} else {
return ((power(a, b / 2))) * ((power(a, b / 2)));
}
}
}
//--------------------------------------lower bound----------------------------------------------------------
static int LowerBound(int a[], int x)
{ // x is the target value or key
int l=-1,r=a.length;
while(l+1<r) {
int m=(l+r)>>>1;
if(a[m]>=x) r=m;
else l=m;
}
return r;
}
//--------------------------------------------------------------------------------------------------------------
public static int log2(int x) {
return (int) (Math.log(x) / Math.log(2));
}
//---------------------------------------EXTENDED EUCLID ALGO--------------------------------------------------------
/* public static class Pair{
int x;
int y;
public Pair(int x,int y){
this.x = x;
this.y = y ;
}
}
*/
public static Pair Euclid(int a,int b){
if(b==0){
return new Pair(1,0); // answer of x and y
}
Pair dash = Euclid(b,a%b);
return new Pair(dash.y , dash.x - (a/b)*dash.y);
}
//--------------------------------GCD------------------GCD-----------GCD--------------------------------------------
public static long gcd(long a,long b){
if(b==0){
return a;
}
return gcd(b,a%b);
}
public static void BFS(ArrayList<Integer>[] graph) {
}
} | Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | e5e0a07ec882ec77cbae596539b3c358 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.Scanner;
public class ColoringRectangles {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while (t-->0){
int n = in.nextInt();
int m = in.nextInt();
System.out.println((n*m+2)/3);
}
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | a7359997e733c1dd7ae27ca4328bd0d6 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
public class codeforcesA{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
static int gcd(int a,int b){if(b==0){return a;}return gcd(b,a%b);}
public static void main(String args[]){
FastReader sc=new FastReader();
int t=sc.nextInt();
StringBuilder sb=new StringBuilder();
while(t-->0){
//aa,aba,aca,abca,acba,abbacca,accabba
int n=sc.nextInt();
int m=sc.nextInt();
int mul=n*m;
int ans=(mul)/3;
if(mul%3!=0){ans++;}
System.out.println(ans);
}
}
} | Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 90f273e3b637b286f1eb224ee40ca182 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | /* package codechef; // don't place package name! */
import java.io.*;
public final class P {
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int tt=Integer.parseInt(br.readLine()),a=0,b=0,l=0,c=0,c1=0;
double d=0;
long n=0,t=0,m=0;
for(int i=1;i<=tt;i++)
{
String arg[]=br.readLine().split(" ");
m=Long.parseLong(arg[0]);
n=Long.parseLong(arg[1]);
t=m*n;
if(t%3==0)
System.out.println(t/3);
else
System.out.println(t/3+1);
}
}
}
| Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | a4b6cc7a1c7fe3a5684241a42f996ae5 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.util.Scanner;
public class MyClass {
static Scanner in=new Scanner(System.in);
static int n,m,testCases;
static void solve(){
int ans=(n*m)%3==0?(int)Math.ceil((n*m)/3 ):(int)Math.ceil((n*m)/3 )+1 ;
System.out.println(ans);
}
public static void main(String args[]) {
testCases=in.nextInt();
for(int i=0;i<testCases;i++){
n=in.nextInt();
m=in.nextInt();
solve();
}
}
} | Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 4f627c08022f49dbb633039e9ac8af64 | train_109.jsonl | 1636869900 | David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Rectangles $$$1 \times 1$$$ are forbidden.David also knows how to paint the cells blue. He wants each rectangle from the resulting set of pieces to be colored such that any pair of adjacent cells by side (from the same piece) have different colors.What is the minimum number of cells David will have to paint? | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Math.*;
import static java.lang.System.out;
import java.util.*;
import java.io.File;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.math.BigInteger;
public class Main {
/* 10^(7) = 1s.
* ceilVal = (a+b-1) / b */
static final int mod = 1000000007;
static final long temp = 998244353;
static final long MOD = 1000000007;
static final long M = (long)1e9+7;
static class Pair implements Comparable<Pair>
{
int first, second;
public Pair(int first, int second)
{
this.first = first;
this.second = second;
}
public int compareTo(Pair ob)
{
return (int)(first - ob.first);
}
}
static class Tuple implements Comparable<Tuple>
{
int first, second,third;
public Tuple(int first, int second, int third)
{
this.first = first;
this.second = second;
this.third = third;
}
public int compareTo(Tuple o)
{
return (int)(o.third - this.third);
}
}
public static class DSU
{
int[] parent;
int[] rank; //Size of the trees is used as the rank
public DSU(int n)
{
parent = new int[n];
rank = new int[n];
Arrays.fill(parent, -1);
Arrays.fill(rank, 1);
}
public int find(int i) //finding through path compression
{
return parent[i] < 0 ? i : (parent[i] = find(parent[i]));
}
public boolean union(int a, int b) //Union Find by Rank
{
a = find(a);
b = find(b);
if(a == b) return false; //if they are already connected we exit by returning false.
// if a's parent is less than b's parent
if(rank[a] < rank[b])
{
//then move a under b
parent[a] = b;
}
//else if rank of j's parent is less than i's parent
else if(rank[a] > rank[b])
{
//then move b under a
parent[b] = a;
}
//if both have the same rank.
else
{
//move a under b (it doesnt matter if its the other way around.
parent[b] = a;
rank[a] = 1 + rank[a];
}
return true;
}
}
static class Reader
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) throws IOException {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long[] longReadArray(int n) throws IOException {
long[] a=new long[n];
for (int i=0; i<n; i++) a[i]=nextLong();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
}
public static int gcd(int a, int b)
{
if(b == 0)
return a;
else
return gcd(b,a%b);
}
public static long lcm(long a, long b)
{
return (a / LongGCD(a, b)) * b;
}
public static long LongGCD(long a, long b)
{
if(b == 0)
return a;
else
return LongGCD(b,a%b);
}
public static long LongLCM(long a, long b)
{
return (a / LongGCD(a, b)) * b;
}
//Count the number of coprime's upto N
public static long phi(long n) //euler totient/phi function
{
long ans = n;
// for(long i = 2;i*i<=n;i++)
// {
// if(n%i == 0)
// {
// while(n%i == 0) n/=i;
// ans -= (ans/i);
// }
// }
//
// if(n > 1)
// {
// ans -= (ans/n);
// }
for(long i = 2;i<=n;i++)
{
if(isPrime(i))
{
ans -= (ans/i);
}
}
return ans;
}
public static long fastPow(long x, long n)
{
if(n == 0)
return 1;
else if(n%2 == 0)
return fastPow(x*x,n/2);
else
return x*fastPow(x*x,(n-1)/2);
}
public static long modPow(long x, long y, long p)
{
long res = 1;
x = x % p;
while (y > 0) {
if (y % 2 == 1)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
static long modInverse(long n, long p)
{
return modPow(n, p - 2, p);
}
// Returns nCr % p using Fermat's little theorem.
public static long nCrModP(long n, long r,long p)
{
if (n<r)
return 0;
if (r == 0)
return 1;
long[] fac = new long[(int)(n) + 1];
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % p;
return (fac[(int)(n)] * modInverse(fac[(int)(r)], p)
% p * modInverse(fac[(int)(n - r)], p)
% p)
% p;
}
public static long fact(long n)
{
long[] fac = new long[(int)(n) + 1];
fac[0] = 1;
for (long i = 1; i <= n; i++)
fac[(int)(i)] = fac[(int)(i - 1)] * i;
return fac[(int)(n)];
}
public static long nCr(long n, long k)
{
long ans = 1;
for(long i = 0;i<k;i++)
{
ans *= (n-i);
ans /= (i+1);
}
return ans;
}
//Modular Operations for Addition and Multiplication.
public static long perfomMod(long x)
{
return ((x%M + M)%M);
}
public static long addMod(long a, long b)
{
return perfomMod(perfomMod(a)+perfomMod(b));
}
public static long subMod(long a, long b)
{
return perfomMod(perfomMod(a)-perfomMod(b));
}
public static long mulMod(long a, long b)
{
return perfomMod(perfomMod(a)*perfomMod(b));
}
public static boolean isPrime(long n)
{
if(n == 1)
{
return false;
}
//check only for sqrt of the number as the divisors
//keep repeating so only half of them are required. So,sqrt.
for(int i = 2;i*i<=n;i++)
{
if(n%i == 0)
{
return false;
}
}
return true;
}
public static List<Long> SieveList(int n)
{
boolean prime[] = new boolean[(int)(n+1)];
Arrays.fill(prime, true);
List<Long> l = new ArrayList<>();
for (long p = 2; p*p<=n; p++)
{
if (prime[(int)(p)] == true)
{
for(long i = p*p; i<=n; i += p)
{
prime[(int)(i)] = false;
}
}
}
for (long p = 2; p<=n; p++)
{
if (prime[(int)(p)] == true)
{
l.add(p);
}
}
return l;
}
public static int countDivisors(int x)
{
int c = 0;
for(int i = 1;i*i<=x;i++)
{
if(x%i == 0)
{
if(x/i != i)
{
c+=2;
}
else
{
c++;
}
}
}
return c;
}
public static long log2(long n)
{
long ans = (long)(log(n)/log(2));
return ans;
}
public static boolean isPow2(long n)
{
return (n != 0 && ((n & (n-1))) == 0);
}
public static boolean isSq(int x)
{
long s = (long)Math.round(Math.sqrt(x));
return s*s==x;
}
/*
*
* >= <=
0 1 2 3 4 5 6 7
5 5 5 6 6 6 7 7
lower_bound for 6 at index 3 (>=)
upper_bound for 6 at index 6(To get six reduce by one) (<=)
*/
public static int LowerBound(long a[], long x)
{
int l=-1,r=a.length;
while(l+1<r)
{
int m=(l+r)>>>1;
if(a[m]>=x) r=m;
else l=m;
}
return r;
}
public static int UpperBound(long a[], long x)
{
int l=-1, r=a.length;
while(l+1<r)
{
int m=(l+r)>>>1;
if(a[m]<=x) l=m;
else r=m;
}
return l+1;
}
public static void Sort(int[] a)
{
List<Integer> l = new ArrayList<>();
for (int i : a) l.add(i);
Collections.sort(l);
// Collections.reverse(l); //Use to Sort decreasingly
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
public static void ssort(char[] a)
{
List<Character> l = new ArrayList<>();
for (char i : a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
public static void main(String[] args) throws Exception
{
Reader sc = new Reader();
PrintWriter fout = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-- > 0)
{
long n = sc.nextLong(), m = sc.nextLong();
fout.println((n * m + 2)/3);
}
fout.close();
}
} | Java | ["4\n1 3\n2 2\n2 5\n3 5"] | 1 second | ["1\n2\n4\n5"] | NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case: | Java 8 | standard input | [
"greedy",
"math"
] | 70a0b98f2bb12990a0fa46aaf13134af | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$). | 1,000 | For each test case print a single integer — the minimum number of cells David will have to paint blue. | standard output | |
PASSED | 8ec4fa9c2a61d770721e7f0b04128e17 | train_109.jsonl | 1636869900 | This is an interactive problem.Jury initially had a sequence $$$a$$$ of length $$$n$$$, such that $$$a_i = i$$$.The jury chose three integers $$$i$$$, $$$j$$$, $$$k$$$, such that $$$1 \leq i < j < k \leq n$$$, $$$j - i > 1$$$. After that, Jury reversed subsegments $$$[i, j - 1]$$$ and $$$[j, k]$$$ of the sequence $$$a$$$.Reversing a subsegment $$$[l, r]$$$ of the sequence $$$a$$$ means reversing the order of elements $$$a_l, a_{l+1}, \ldots, a_r$$$ in the sequence, i. e. $$$a_l$$$ is swapped with $$$a_r$$$, $$$a_{l+1}$$$ is swapped with $$$a_{r-1}$$$, etc.You are given the number $$$n$$$ and you should find $$$i$$$, $$$j$$$, $$$k$$$ after asking some questions.In one question you can choose two integers $$$l$$$ and $$$r$$$ ($$$1 \leq l \leq r \leq n$$$) and ask the number of inversions on the subsegment $$$[l, r]$$$ of the sequence $$$a$$$. You will be given the number of pairs $$$(i, j)$$$ such that $$$l \leq i < j \leq r$$$, and $$$a_i > a_j$$$.Find the chosen numbers $$$i$$$, $$$j$$$, $$$k$$$ after at most $$$40$$$ questions.The numbers $$$i$$$, $$$j$$$, and $$$k$$$ are fixed before the start of your program and do not depend on your queries. | 256 megabytes | import java.util.*;
import java.io.*;
public class D {
static Scanner sc = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) {
final String req = "? %s %s\n";
final String ans = "! %s %s %s\n";
int t = sc.nextInt();
for (; t > 0; t--) {
int n = sc.nextInt();
long a = req(1, n);
if (a == -1)
return;
int lo = 1;
int hi = n;
while (lo < hi-1) {
int mid = mean(lo, hi);
long x = req(mid, n);
if (x == -1)
return;
if (x == a)
lo = mid;
else
hi = mid;
}
int i = lo;
if (a == 1) {
out.printf(ans, i-1, i, i+1);
continue;
}
long b = req(i+1, n);
if (b == -1)
return;
int d = (int) (a - b);
int j = i+d+1;
long L = req(i, j-1);
long R = a - L;
long D = (long) Math.ceil(Math.sqrt(1 + 8*R));
long l = (1 + D) / 2;
long k = j+l-1;
out.printf(ans, i, j, k);
out.flush();
}
out.close();
sc.close();
}
private static int clamp(int x, int max) {
return x > max ? max : x;
}
private static int mean(int a, int b) {
return (a + b) / 2;
}
private static long req(int l, int r) {
out.printf("? %s %s\n", l, r);
out.flush();
return sc.nextLong();
}
}
| Java | ["2 \n5 \n\n4 \n\n3 \n\n3 \n\n5 \n\n2 \n\n2 \n\n1"] | 1 second | ["? 1 5\n\n? 2 5\n\n? 3 5\n\n! 1 3 5\n\n? 1 5\n\n? 2 5\n\n? 3 5\n\n! 2 4 5"] | NoteIn the first test case, $$$i = 1$$$, $$$j = 3$$$, $$$k = 5$$$, so the sequence $$$a$$$ is $$$[2, 1, 5, 4, 3]$$$.In the second test case, $$$i = 2$$$, $$$j = 4$$$, $$$k = 5$$$, so the sequence $$$a$$$ is $$$[1, 3, 2, 5, 4]$$$. | Java 11 | standard input | [
"binary search",
"combinatorics",
"interactive",
"math"
] | 6be52845d61d8fbd297d742842acd28e | Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. Description of the test cases follows. The single line of each test case contains a single integer $$$n$$$ ($$$4 \leq n \leq 10^9$$$). After reading it you should start an interaction process by asking questions for that test case. After giving an answer you should: Terminate your program if that is the last test case. Proceed to the next test case otherwise. | 2,000 | null | standard output | |
PASSED | 9f60709769bfb9360f8c138f6a8db2f6 | train_109.jsonl | 1636869900 | This is an interactive problem.Jury initially had a sequence $$$a$$$ of length $$$n$$$, such that $$$a_i = i$$$.The jury chose three integers $$$i$$$, $$$j$$$, $$$k$$$, such that $$$1 \leq i < j < k \leq n$$$, $$$j - i > 1$$$. After that, Jury reversed subsegments $$$[i, j - 1]$$$ and $$$[j, k]$$$ of the sequence $$$a$$$.Reversing a subsegment $$$[l, r]$$$ of the sequence $$$a$$$ means reversing the order of elements $$$a_l, a_{l+1}, \ldots, a_r$$$ in the sequence, i. e. $$$a_l$$$ is swapped with $$$a_r$$$, $$$a_{l+1}$$$ is swapped with $$$a_{r-1}$$$, etc.You are given the number $$$n$$$ and you should find $$$i$$$, $$$j$$$, $$$k$$$ after asking some questions.In one question you can choose two integers $$$l$$$ and $$$r$$$ ($$$1 \leq l \leq r \leq n$$$) and ask the number of inversions on the subsegment $$$[l, r]$$$ of the sequence $$$a$$$. You will be given the number of pairs $$$(i, j)$$$ such that $$$l \leq i < j \leq r$$$, and $$$a_i > a_j$$$.Find the chosen numbers $$$i$$$, $$$j$$$, $$$k$$$ after at most $$$40$$$ questions.The numbers $$$i$$$, $$$j$$$, and $$$k$$$ are fixed before the start of your program and do not depend on your queries. | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
OutputWriter out = new OutputWriter(outputStream);
DGuessThePermutation solver = new DGuessThePermutation();
int testCount = Integer.parseInt(in.next());
for (int i = 1; i <= testCount; i++)
solver.solve(i, in, out);
out.close();
}
static class DGuessThePermutation {
public void solve(int testNumber, InputReader in, OutputWriter out) {
int n = in.nextInt();
long y = query(1, n, in);
int lo = 1;
int hi = n;
int end = n;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (query(mid, n, in) < 1) {
if (mid != n)
end = mid;
hi = mid - 1;
} else {
lo = mid + 1;
}
}
int l = (int) (query(1, end, in) - query(1, end - 1, in));
int j = end - l;
int st = 1;
if (j - 2 >= 0) {
l = (int) (query(1, j - 1, in) - query(1, j - 2, in));
st = j - 1 - l;
}
System.out.println("! " + st + " " + j + " " + end);
}
long query(int l, int r, InputReader in) {
System.out.println("? " + l + " " + r);
return in.nextLong();
}
}
static class OutputWriter {
private final PrintWriter writer;
public OutputWriter(OutputStream outputStream) {
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
}
public OutputWriter(Writer writer) {
this.writer = new PrintWriter(writer);
}
public void close() {
writer.close();
}
}
static class InputReader {
BufferedReader reader;
StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
}
}
| Java | ["2 \n5 \n\n4 \n\n3 \n\n3 \n\n5 \n\n2 \n\n2 \n\n1"] | 1 second | ["? 1 5\n\n? 2 5\n\n? 3 5\n\n! 1 3 5\n\n? 1 5\n\n? 2 5\n\n? 3 5\n\n! 2 4 5"] | NoteIn the first test case, $$$i = 1$$$, $$$j = 3$$$, $$$k = 5$$$, so the sequence $$$a$$$ is $$$[2, 1, 5, 4, 3]$$$.In the second test case, $$$i = 2$$$, $$$j = 4$$$, $$$k = 5$$$, so the sequence $$$a$$$ is $$$[1, 3, 2, 5, 4]$$$. | Java 11 | standard input | [
"binary search",
"combinatorics",
"interactive",
"math"
] | 6be52845d61d8fbd297d742842acd28e | Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. Description of the test cases follows. The single line of each test case contains a single integer $$$n$$$ ($$$4 \leq n \leq 10^9$$$). After reading it you should start an interaction process by asking questions for that test case. After giving an answer you should: Terminate your program if that is the last test case. Proceed to the next test case otherwise. | 2,000 | null | standard output | |
PASSED | 036e8d213313b983520dad8216556f0b | train_109.jsonl | 1636869900 | This is an interactive problem.Jury initially had a sequence $$$a$$$ of length $$$n$$$, such that $$$a_i = i$$$.The jury chose three integers $$$i$$$, $$$j$$$, $$$k$$$, such that $$$1 \leq i < j < k \leq n$$$, $$$j - i > 1$$$. After that, Jury reversed subsegments $$$[i, j - 1]$$$ and $$$[j, k]$$$ of the sequence $$$a$$$.Reversing a subsegment $$$[l, r]$$$ of the sequence $$$a$$$ means reversing the order of elements $$$a_l, a_{l+1}, \ldots, a_r$$$ in the sequence, i. e. $$$a_l$$$ is swapped with $$$a_r$$$, $$$a_{l+1}$$$ is swapped with $$$a_{r-1}$$$, etc.You are given the number $$$n$$$ and you should find $$$i$$$, $$$j$$$, $$$k$$$ after asking some questions.In one question you can choose two integers $$$l$$$ and $$$r$$$ ($$$1 \leq l \leq r \leq n$$$) and ask the number of inversions on the subsegment $$$[l, r]$$$ of the sequence $$$a$$$. You will be given the number of pairs $$$(i, j)$$$ such that $$$l \leq i < j \leq r$$$, and $$$a_i > a_j$$$.Find the chosen numbers $$$i$$$, $$$j$$$, $$$k$$$ after at most $$$40$$$ questions.The numbers $$$i$$$, $$$j$$$, and $$$k$$$ are fixed before the start of your program and do not depend on your queries. | 256 megabytes | import java.lang.Math;
import java.util.*;
import java.io.*;
import java.lang.Math;
public final class code {
boolean isSub;
code() {
this.isSub = false;
}
static class sortCond implements Comparator<Pair<Integer, Integer>> {
@Override
public int compare(Pair<Integer, Integer> obj, Pair<Integer, Integer> obj1) {
if (obj.getValue() < obj1.getValue()) {
return -1;
} else {
return 1;
}
}
}
static class Pair<f, s> {
f a;
s b;
Pair(f a, s b) {
this.a = a;
this.b = b;
}
f getKey() {
return this.a;
}
s getValue() {
return this.b;
}
}
interface modOperations {
long mod(long a, long b, long mod);
}
static long findBinaryExponentian(long a, long pow, long mod) {
if (pow == 1) {
return a;
} else if (pow == 0) {
return 1;
} else {
long retVal = findBinaryExponentian(a, (int) pow / 2, mod);
return modMul.mod(modMul.mod(retVal, retVal, mod), (pow % 2 == 0) ? 1 : a, mod);
}
}
static int bleft(int ele, ArrayList<Integer> sortedArr) {
int l = 0;
int h = sortedArr.size() - 1;
int ans = -1;
while (l <= h) {
int mid = l + (int) (h - l) / 2;
if (sortedArr.get(mid) < ele) {
l = mid + 1;
} else if (sortedArr.get(mid) >= ele) {
ans = mid;
h = mid - 1;
}
}
return ans;
}
static long gcd(long a, long b) {
long div = b;
long rem = a % b;
while (rem != 0) {
long temp = rem;
rem = div % rem;
div = temp;
}
return div;
}
static int log(long no) {
int i = 0;
while ((1 << i) <= no) {
i += 1;
}
return i - 1;
}
static modOperations modAdd = (long a, long b, long mod) -> {
return (a % mod + b % mod) % mod;
};
static modOperations modSub = (long a, long b, long mod) -> {
return (a % mod - b % mod + mod) % mod;
};
static modOperations modMul = (long a, long b, long mod) -> {
return (a % mod * b % mod) % mod;
};
static modOperations modDiv = (long a, long b, long mod) -> {
return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
};
static ArrayList<Integer> primeList(int MAXI) {
int[] prime = new int[MAXI + 1];
ArrayList<Integer> obj = new ArrayList<Integer>();
for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
if (prime[i] == 0) {
obj.add(i);
for (int j = i * i; j <= MAXI; j += i) {
prime[j] = 1;
}
}
}
for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
if (prime[i] == 0) {
obj.add(i);
}
}
return obj;
}
static boolean dfs(ArrayList<ArrayList<Integer>> g, boolean[] vis, int root, int req) {
if (root == req - 1) {
return true;
}
boolean res = false;
for (int i = 0; i < g.get(root).size(); i++) {
if (!vis[g.get(root).get(i)]) {
vis[g.get(root).get(i)] = true;
res = res || dfs(g, vis, g.get(root).get(i), req);
}
}
return res;
}
static void dfs1(ArrayList<ArrayList<Integer>> g, ArrayList<Integer> store, boolean[] vis, int root) {
for (int i = 0; i < g.get(root).size(); i++) {
if (!vis[g.get(root).get(i)]) {
vis[g.get(root).get(i)] = true;
dfs1(g, store, vis, g.get(root).get(i));
}
}
store.add(root);
}
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(br.readLine());
for(int i=0;i<t;i++){
long n = Long.parseLong(br.readLine());
long l = 1, h = n, mid;
System.out.println("?" + " " + 1 + " " + n);
System.out.flush();
long tot = Long.parseLong(br.readLine());
long ans = -1;
long no = -1;
while (l <= h) {
mid = l + (int) (h - l) / 2;
System.out.println("?" + " " + 1 + " " + mid);
System.out.flush();
long temp = Long.parseLong(br.readLine());
if (temp < tot) {
l = mid + 1;
} else {
ans = mid;
no=temp;
h = mid - 1;
}
}
System.out.println("?" + " " + 1 + " " + (ans - 1));
System.out.flush();
long j = ans - (no-Long.parseLong(br.readLine()));
System.out.println("?" + " " + 1 + " " + (j - 1));
System.out.flush();
long jmin = Long.parseLong(br.readLine());
System.out.println("?" + " " + 1 + " " + (j - 2));
System.out.flush();
long ii = Long.parseLong(br.readLine());
ii = j-1-(jmin-ii);
System.out.println("!"+" "+ii+" "+j+" "+ans);
System.out.flush();
}
}
} | Java | ["2 \n5 \n\n4 \n\n3 \n\n3 \n\n5 \n\n2 \n\n2 \n\n1"] | 1 second | ["? 1 5\n\n? 2 5\n\n? 3 5\n\n! 1 3 5\n\n? 1 5\n\n? 2 5\n\n? 3 5\n\n! 2 4 5"] | NoteIn the first test case, $$$i = 1$$$, $$$j = 3$$$, $$$k = 5$$$, so the sequence $$$a$$$ is $$$[2, 1, 5, 4, 3]$$$.In the second test case, $$$i = 2$$$, $$$j = 4$$$, $$$k = 5$$$, so the sequence $$$a$$$ is $$$[1, 3, 2, 5, 4]$$$. | Java 11 | standard input | [
"binary search",
"combinatorics",
"interactive",
"math"
] | 6be52845d61d8fbd297d742842acd28e | Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. Description of the test cases follows. The single line of each test case contains a single integer $$$n$$$ ($$$4 \leq n \leq 10^9$$$). After reading it you should start an interaction process by asking questions for that test case. After giving an answer you should: Terminate your program if that is the last test case. Proceed to the next test case otherwise. | 2,000 | null | standard output | |
PASSED | 02abc906195c688a404b5c57c9b11374 | train_109.jsonl | 1636869900 | This is an interactive problem.Jury initially had a sequence $$$a$$$ of length $$$n$$$, such that $$$a_i = i$$$.The jury chose three integers $$$i$$$, $$$j$$$, $$$k$$$, such that $$$1 \leq i < j < k \leq n$$$, $$$j - i > 1$$$. After that, Jury reversed subsegments $$$[i, j - 1]$$$ and $$$[j, k]$$$ of the sequence $$$a$$$.Reversing a subsegment $$$[l, r]$$$ of the sequence $$$a$$$ means reversing the order of elements $$$a_l, a_{l+1}, \ldots, a_r$$$ in the sequence, i. e. $$$a_l$$$ is swapped with $$$a_r$$$, $$$a_{l+1}$$$ is swapped with $$$a_{r-1}$$$, etc.You are given the number $$$n$$$ and you should find $$$i$$$, $$$j$$$, $$$k$$$ after asking some questions.In one question you can choose two integers $$$l$$$ and $$$r$$$ ($$$1 \leq l \leq r \leq n$$$) and ask the number of inversions on the subsegment $$$[l, r]$$$ of the sequence $$$a$$$. You will be given the number of pairs $$$(i, j)$$$ such that $$$l \leq i < j \leq r$$$, and $$$a_i > a_j$$$.Find the chosen numbers $$$i$$$, $$$j$$$, $$$k$$$ after at most $$$40$$$ questions.The numbers $$$i$$$, $$$j$$$, and $$$k$$$ are fixed before the start of your program and do not depend on your queries. | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
public class Codeforces {
static String ab,b;
static class Node
{
int val;
Node left;
Node right;
public Node(int x) {
// TODO Auto-generated constructor stub
this.val=x;
this.left=null;
this.right=null;
}
}
static class Pair<U, V> implements Comparable<Pair<U, V>> {
public U x;
public V y;
public Pair(U x, V y) {
this.x = x;
this.y = y;
}
public int compareTo(Pair<U, V> o) {
int value = ((Comparable<U>) x).compareTo(o.x);
if (value != 0) return value;
return ((Comparable<V>) y).compareTo(o.y);
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Pair<?, ?> pair = (Pair<?, ?>) o;
return x.equals(pair.x) && y.equals(pair.y);
}
public int hashCode() {
return Objects.hash(x, y);
}
}
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
int[] nextArray(int n)
{
int arr[]=new int[n];
for(int i=0;i<n;i++)
arr[i]=nextInt();
return arr;
}
}
static String string;
static int gcd(int a, int b)
{
// Everything divides 0
if (a == 0)
return b;
if (b == 0)
return a;
// base case
if (a == b)
return a;
// a is greater
return gcd(b, a % b);
}
static long gcd(long a, long b)
{
// Everything divides 0
for(long i=2;i<=b;i++)
{
if(a%i==0&&b%i==0)
return i;
}
return 1;
}
static int fac(int n)
{
int c=1;
for(int i=2;i<n;i++)
if(n%i==0)
c=i;
return c;
}
static int lcm(int a,int b)
{
for(int i=Math.min(a, b);i<=a*b;i++)
if(i%a==0&&i%b==0)
return i;
return 0;
}
static int maxHeight(char[][] ch,int i,int j,String[] arr)
{
int h=1;
if(i==ch.length-1||j==0||j==ch[0].length-1)
return 1;
while(i+h<ch.length&&j-h>=0&&j+h<ch[0].length&&ch[i+h][j-h]=='*'&&ch[i+h][j+h]=='*')
{
String whole=arr[i+h];
//System.out.println(whole.substring(j-h,j+h+1));
if(whole.substring(j-h,j+h+1).replace("*","").length()>0)
return h;
h++;
}
return h;
}
static boolean all(BigInteger n)
{
BigInteger c=n;
HashSet<Character> hs=new HashSet<>();
while((c+"").compareTo("0")>0)
{
String d=""+c;
char ch=d.charAt(d.length()-1);
if(d.length()==1)
{
c=new BigInteger("0");
}
else
c=new BigInteger(d.substring(0,d.length()-1));
if(hs.contains(ch))
continue;
if(d.charAt(d.length()-1)=='0')
continue;
if(!(n.mod(new BigInteger(""+ch)).equals(new BigInteger("0"))))
return false;
hs.add(ch);
}
return true;
}
static int cal(long n,long k)
{
System.out.println(n+","+k);
if(n==k)
return 2;
if(n<k)
return 1;
if(k==1)
return 1+cal(n, k+1);
if(k>=32)
return 1+cal(n/k, k);
return 1+Math.min(cal(n/k, k),cal(n, k+1));
}
static Node buildTree(int i,int j,int[] arr)
{
if(i==j)
{
//System.out.print(arr[i]);
return new Node(arr[i]);
}
int max=i;
for(int k=i+1;k<=j;k++)
{
if(arr[max]<arr[k])
max=k;
}
Node root=new Node(arr[max]);
//System.out.print(arr[max]);
if(max>i)
root.left=buildTree(i, max-1, arr);
else {
root.left=null;
}
if(max<j)
root.right=buildTree(max+1, j, arr);
else {
root.right=null;
}
return root;
}
static int height(Node root,int val)
{
if(root==null)
return Integer.MAX_VALUE-32;
if(root.val==val)
return 0;
if((root.left==null&&root.right==null))
return Integer.MAX_VALUE-32;
return Math.min(height(root.left, val), height(root.right, val))+1;
}
static void shuffle(int a[], int n)
{
for (int i = 0; i < n; i++) {
// getting the random index
int t = (int)Math.random() * a.length;
// and swapping values a random index
// with the current index
int x = a[t];
a[t] = a[i];
a[i] = x;
}
}
static void sort(int[] arr )
{
shuffle(arr, arr.length);
Arrays.sort(arr);
}
static boolean arraySortedInc(int arr[], int n)
{
// Array has one or no element
if (n == 0 || n == 1)
return true;
for (int i = 1; i < n; i++)
// Unsorted pair found
if (arr[i - 1] > arr[i])
return false;
// No unsorted pair found
return true;
}
static boolean arraySortedDec(int arr[], int n)
{
// Array has one or no element
if (n == 0 || n == 1)
return true;
for (int i = 1; i < n; i++)
// Unsorted pair found
if (arr[i - 1] > arr[i])
return false;
// No unsorted pair found
return true;
}
static int largestPower(int n, int p) {
// Initialize result
int x = 0;
// Calculate x = n/p + n/(p^2) + n/(p^3) + ....
while (n > 0) {
n /= p;
x += n;
}
return x;
}
// Utility function to do modular exponentiation.
// It returns (x^y) % p
static int power(int x, int y, int p) {
int res = 1; // Initialize result
x = x % p; // Update x if it is more than or
// equal to p
while (y > 0) {
// If y is odd, multiply x with result
if (y % 2 == 1) {
res = (res * x) % p;
}
// y must be even now
y = y >> 1; // y = y/2
x = (x * x) % p;
}
return res;
}
// Returns n! % p
static int modFact(int n, int p) {
if (n >= p) {
return 0;
}
int res = 1;
// Use Sieve of Eratosthenes to find all primes
// smaller than n
boolean isPrime[] = new boolean[n + 1];
Arrays.fill(isPrime, true);
for (int i = 2; i * i <= n; i++) {
if (isPrime[i]) {
for (int j = 2 * i; j <= n; j += i) {
isPrime[j] = false;
}
}
}
// Consider all primes found by Sieve
for (int i = 2; i <= n; i++) {
if (isPrime[i]) {
// Find the largest power of prime 'i' that divides n
int k = largestPower(n, i);
// Multiply result with (i^k) % p
res = (res * power(i, k, p)) % p;
}
}
return res;
}
static boolean[] seiveOfErathnos(int n2)
{
boolean isPrime[] = new boolean[n2 + 1];
Arrays.fill(isPrime, true);
for (int i = 2; i * i <= n2; i++) {
if (isPrime[i]) {
for (int j = 2 * i; j <= n2; j += i) {
isPrime[j] = false;
}
}
}
return isPrime;
}
static boolean[] seiveOfErathnos2(int n2,int[] ans)
{
boolean isPrime[] = new boolean[n2 + 1];
Arrays.fill(isPrime, true);
for (int i = 2; i * i <= n2; i++) {
if (isPrime[i]) {
for (int j = 2 * i; j <= n2; j += i) {
if(isPrime[j])
ans[i]++;
isPrime[j] = false;
}
}
}
return isPrime;
}
static int calculatePower(PriorityQueue<Integer>[] list,int[] alive)
{
// List<Integer> dead=new ArrayList<>();
for(int i=1;i<alive.length;i++)
{
if(alive[i]==1)
{
if(list[i].size()==0)
{
continue;
}
if(list[i].peek()>i)
{
// dead.add(i);
// System.out.println(i);
alive[i]=0;
for(int j:list[i])
{
// list[i].remove((Integer)j);
list[j].remove((Integer)i);
}
list[i].clear();
return 1+calculatePower(list,alive);
}
}
}
return 0;
}
static boolean helper(int i,int j,int[] index,int k,HashMap<String,String> hm)
{
// System.out.println(i+","+j);
if(k<=0)
return false;
if(i==j)
return true;
String key=i+","+j;
if(hm.containsKey(key))
{
String[] all=hm.get(key).split(",");
int prev=Integer.parseInt(all[0]);
// String val=Integer.parseInt(all[1]);
if(prev==k)
return all[1].equals("true")?true:false;
else if(prev>k&&all[1].equals("false"))
return false;
else if(prev<k&&all[1].equals("true"))
return true;
}
if(i+1==j)
{
if(index[i]+1==index[j]||k>=2)
return true;
return false;
}
boolean flag=false;
for(int p=i;p<j;p++)
{
if(index[p]+1!=index[p+1])
{
flag=true;
break;
}
}
if(!flag)
{
hm.put(key,k+","+ true);
return true;
}
if(k==1)
{
hm.put(key,k+","+ false);
return false;
}
for(int p=i;p<j;p++)
{
if(helper(i,p,index,k-1,hm)&&helper(p+1,j,index,k-1,hm))
{
hm.put(key,k+","+ true);
return true;
}
}
hm.put(key, k+","+false);
return false;
}
static int set(int[] arr,int start)
{
int count=0;
for(int i=0;i<arr.length;i++)
{
if(arr[i]%2==0)
{
count+=Math.abs(start-i);
start+=2;
}
}
return count;
}
public static void main(String[] args)throws IOException
{
BufferedReader bReader=new BufferedReader(new InputStreamReader(System.in));
FastReader fs=new FastReader();
// int[] ans=new int[1000001];
int T=fs.nextInt();
// seiveOfErathnos2(1000000, ans);
StringBuilder sb=new StringBuilder();
while(T-->0)
{
int n=fs.nextInt();
long l=1,h=n,i=0;
System.out.println("? "+1+" "+n);
// int all=fs.nextInt();
long all=fs.nextLong();
System.out.flush();
while(l<h)
{
long mid=l+(h-l)/2;
System.out.println("? "+mid+" "+n);
// int x=fs.nextInt();
long x=fs.nextLong();
System.out.flush();
if(x==all)
{
i=mid;
l=mid+1;
}
else if(x<all)
h=mid;
}
System.out.println("? "+(i+1)+" "+n);
// int x=fs.nextInt();
long x=fs.nextLong();
System.out.flush();
long j=all-x+i+1;
System.out.println("? "+(j)+" "+n);
// x=fs.nextInt();
long y=fs.nextLong();
System.out.flush();
System.out.println("? "+(j+1)+" "+n);
// x=fs.nextInt();
x=fs.nextLong();
// x=y-x+2;
System.out.flush();
long k=y-x+j;
System.out.println("! "+i+" "+j+" "+k);
// sb.append(ans?"YES":"NO");
// int[] arr=fs.nextArray(n);
// System.out.println();
// sb.append(ans);
sb.append("\n");
}
System.out.println(sb);
}
} | Java | ["2 \n5 \n\n4 \n\n3 \n\n3 \n\n5 \n\n2 \n\n2 \n\n1"] | 1 second | ["? 1 5\n\n? 2 5\n\n? 3 5\n\n! 1 3 5\n\n? 1 5\n\n? 2 5\n\n? 3 5\n\n! 2 4 5"] | NoteIn the first test case, $$$i = 1$$$, $$$j = 3$$$, $$$k = 5$$$, so the sequence $$$a$$$ is $$$[2, 1, 5, 4, 3]$$$.In the second test case, $$$i = 2$$$, $$$j = 4$$$, $$$k = 5$$$, so the sequence $$$a$$$ is $$$[1, 3, 2, 5, 4]$$$. | Java 8 | standard input | [
"binary search",
"combinatorics",
"interactive",
"math"
] | 6be52845d61d8fbd297d742842acd28e | Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. Description of the test cases follows. The single line of each test case contains a single integer $$$n$$$ ($$$4 \leq n \leq 10^9$$$). After reading it you should start an interaction process by asking questions for that test case. After giving an answer you should: Terminate your program if that is the last test case. Proceed to the next test case otherwise. | 2,000 | null | standard output | |
PASSED | fab39ffad47a96e6b195d018a62f671d | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class CodeForcesTest {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int noOfTest = sc.nextInt();
for(int j=0; j<noOfTest; j++) {
long u = sc.nextLong();
long v = sc.nextLong();
long y = v*v;
long x = -u*u;
System.out.println(x +" " +y);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | ae245950d1492b6ec79477398f6f0852 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
import java.io.*;
public class CFsolve {
public static void main(String[] args) {
FastScanner input = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int t = input.nextInt();
while(t-- > 0){
long u = input.nextInt();
long v = input.nextInt();
out.println((long)(-1)*u*u +" "+ v*v);
}
out.close();
}
static int LCM(int a, int b){
return a/gcd(a,b) * b;
}
static long LCM(long a, long b){
return (a/gcd(a,b) * b);
}
static int gcd(int a,int b){
while(b>0){
a%=b;
a=a^b;
b=a^b;
a=a^b;
}
return a;
}
static long gcd(long a,long b){
while(b>0){
a%=b;
a=a^b;
b=a^b;
a=a^b;
}
return a;
}
static void swap(int a, int b){
a = a^b;
b = a^b;
a = a^b;
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
byte nextByte(){return Byte.parseByte(next());}
long nextLong() {
return Long.parseLong(next());
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | d081aee0ac6de4445a422d3817a5af64 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class Ma2 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int loop = s.nextInt();
for (int i = 0; i < loop; i++) {
long u = s.nextInt();
long v = s.nextInt();
System.out.println("-" + u * u + " " + v * v);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | b85cc415a2bb8bee4aebaefa91b78a54 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.math.BigInteger;
import java.util.Scanner;
public class Ma2 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int loop = s.nextInt();
for (int i = 0; i < loop; i++) {
BigInteger u = new BigInteger(s.nextInt()+"") ;
BigInteger v = new BigInteger(s.nextInt()+"") ;
System.out.println("-" + u.pow(2) + " " + v.pow(2));
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 646f753a9d5465127c52cebdbcf388a8 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class main{
public static void main(String [] args)
{
Scanner sc = new Scanner(System.in);
long t = sc.nextInt();
while(t-- >0)
{
long u = sc.nextInt();
long v = sc.nextInt();
System.out.println("-"+u*u+" "+v*v);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 1d187f45553c3f7669c47e6b9ee8595f | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- != 0)
{
Long u = sc.nextLong();
Long v = sc.nextLong();
System.out.println(-u*u + " " + v*v);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 242d4678f53871c7dcdfe119a55c79ef | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.*;
import java.lang.Math;
import java.util.StringTokenizer;
public class twentyseven {
public static void main(String[] args){
int a, b, t;
String str;
FastReader in = new FastReader();
t = in.nextInt();
while(t-- > 0){
long u = in.nextInt();
long v = in.nextInt();
System.out.println(u * u * -1 + " " + v * v);
}
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
int[] readArray(int n){
int[] a = new int[n];
for(int i = 0; i < n;i++){
a[i] = nextInt();
}
return a;
}
String nextLine()
{
String str = "";
try {
if(st.hasMoreTokens()){
str = st.nextToken("\n");
}
else{
str = br.readLine();
}
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | efd06a9f41f5a6ea1b65914400ef60f8 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int z = 0; z < t; z++) {
int u = sc.nextInt();
int v = sc.nextInt();
getPair(u,v);
}
}
public static void getPair(int u, int v) {
long uSq = (long)u*u;
long vSq = (long)v*v;
System.out.println(-uSq+" "+vSq);
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | c481cad6643c5390da8fc3e47c757f49 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class MathematicalAddition {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for (int i=0;i<t;i++){
long u=sc.nextLong(),v=sc.nextLong();
System.out.println(-(u*u)+" "+(v*v));
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 92477036b8ac893de1e6c0ee1e2ed31f | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
public class A
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
long ans = 0;
while(t-->0)
{
long u ;
u = sc.nextLong();
long v = sc.nextLong();
System.out.println((long)(-(u*u))+" "+(long)(v*v));
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 61473ff233b88aef990cad89909bdd3d | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | /*package whatever //do not write package name here */
import java.util.*;
import java.io.*;
public class Solution {
static boolean comp(int freq1[],int freq2[])
{
for(int i=0;i<26;i++)
{
if(freq1[i]!=freq2[i])
{
return false;
}
}
return true;
}
public static void main (String[] args) {
Scanner in = new Scanner(System.in);
int t=in.nextInt();
while(t>0)
{
t--;
int a=in.nextInt();
int b=in.nextInt();
long aa=-(1l*a*a);
long bb=(1l*b*b);
System.out.println(aa + " " + bb);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 16050e87968f05223ca6f82750df98e9 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-->0){
int u = sc.nextInt();
int v = sc.nextInt();
long x = 1l*u*u;
long y = 1l*v*v;
System.out.println("-" + x + " " + y);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | f91c3cc37bc1fcd9c07d0c088e6b126a | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class Sol {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i=0;i<n;i++)
{
long u = sc.nextLong();
long v = sc.nextLong();
long x = -1*u*u;
long y = v*v;
System.out.println(x+" "+y);
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | cb696a2a883ef26f04be4bec983cc8ec | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
public class Main{
public static void main(String ar[]){
Scanner scan=new Scanner(System.in);
int T=scan.nextInt();
for(int i=0;i<T;i++){
long u=scan.nextInt();
long v=scan.nextInt();
long x=-u*u;
long y=v*v;
System.out.print(x+" "+ y);
System.out.println();
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | b74855b5f62ad90fe84fa4714baaa25c | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import jdk.nashorn.internal.runtime.regexp.joni.Regex;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long n = in.nextInt();
ArrayList<ArrayList<Long>> arr = new ArrayList<ArrayList<Long>>();
for (long i = 0; i < n; i++){
ArrayList temp = new ArrayList();
long a = in.nextInt();
long b = in.nextInt();
temp.add(a);
temp.add(b);
arr.add(temp);
}
for (ArrayList<Long> x : arr){
System.out.println((x.get(0) *x.get(0) * -1) +" " +x.get(1) *x.get(1));
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 83e7d0129b888f29ad4d3f6a2a9f7450 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.math.BigInteger;
import java.util.*;
public class test {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while(t-- > 0){
String u = in.next(), v = in.next();
BigInteger b = new BigInteger(u);
BigInteger b1 = new BigInteger(v);
b = b.multiply(b);
b1 = b1.multiply(b1);
System.out.println("-"+b+" "+b1);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | ff77b07416798afcbaba8a210d65b05e | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class A1584 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- != 0) {
long v = sc.nextInt();
long u = sc.nextInt();
System.out.println(-v * v + " " + u * u);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 47566823055b914f12606e450323ee43 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
new Thread(null, () -> new Main().run(), "1", 1 << 23).start();
}
private void run() {
FastReader scan = new FastReader();
PrintWriter out = new PrintWriter(System.out);
Solution solve = new Solution();
int t = scan.nextInt();
// int t = 1;
for (int qq = 0; qq < t; qq++) {
solve.solve(scan, out);
out.println();
}
out.close();
}
}
class Solution {
/*
* think and coding
*/
static long MOD = (long) (1e9);
double EPS = 0.000_0001;
int numberCount = 1;
public void solve(FastReader scan, PrintWriter out) {
long u = scan.nextLong(), v = scan.nextLong();
if (u < v) {
out.println(-1 * u * u + " " + v * v);
} else {
out.println(u * u + " " + v * v * - 1);
}
}
public long math1(long u, long v, long x, long y) {
return x / u + y / v;
}
public long math2(long u, long v, long x, long y) {
return (x + y) / (v + u);
}
int lower(int val, Pair[] arr) {
int l = -1, r = arr.length;
while (r - l > 1) {
int mid = (r + l) / 2;
if (arr[mid].a < val) {
l = mid;
} else r = mid;
}
return r;
}
static class Pair implements Comparable<Pair> {
int a, b;
public Pair(int a, int b) {
this.a = a;
this.b = b;
}
public Pair(Pair p) {
this.a = p.a;
this.b = p.b;
}
@Override
public int compareTo(Pair p) {
return Integer.compare(a, p.a);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Pair pair = (Pair) o;
return a == pair.a && b == pair.b;
}
@Override
public int hashCode() {
return Objects.hash(a, b);
}
@Override
public String toString() {
return "Pair{" + "a=" + a + ", b=" + b + '}';
}
}
}
class FastReader {
private final BufferedReader br;
private StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
public FastReader(String s) throws FileNotFoundException {
br = new BufferedReader(new FileReader(new File(s)));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
int[] initInt(int n) {
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = nextInt();
}
return arr;
}
long[] initLong(int n) {
long[] arr = new long[n];
for (int i = 0; i < n; i++) {
arr[i] = nextLong();
}
return arr;
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | f32a84635d1a5b6a7d221a35c9999133 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Arrays;
public class Cv {
//==========================Solution============================//
public static void main(String[] args) {
FastScanner in = new FastScanner();
Scanner input = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = input.nextInt();
while (t-- > 0) {
long u = input.nextLong();
long v = input.nextLong();
out.println((long)(-1 * u * u) + " " + (long)(v * v));
}
out.close();
}
//==============================================================//
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
public String next() {
while (!st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
public String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
byte nextByte() {
return Byte.parseByte(next());
}
short nextShort() {
return Short.parseShort(next());
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return java.lang.Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | dc0a982889d95127f96b7c0ebbc934c5 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static void main (String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
int tests = Integer.parseInt(in.readLine());
while(tests-->0) {
long[] values = new long[2];
StringTokenizer st = new StringTokenizer(in.readLine());
for(int i = 0; i < values.length; i++) {
values[i] = Long.parseLong(st.nextToken());
}
long u = values[0], v = values[1];
out.write(-(u*u) + " " + (v*v));
out.newLine();
}
out.flush();
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 3cb846baa15a01393f63dab9decc5709 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main
{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
while(t-- != 0) {
String s[] = br.readLine().split(" ");
long u = Long.parseLong(s[0]);
long v = Long.parseLong(s[1]);
System.out.println((-1 * u * u) +" "+ (v * v));
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 8d9eed1ae96a28c3e0625a6e8177382b | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static class Pair implements Comparable < Pair > {
int d;
int i;
Pair(int d, int i) {
this.d = d;
this.i = i;
}
public int compareTo(Pair o) {
return this.d - o.d;
}
}
public static class SegmentTree {
long[] st;
long[] lazy;
int n;
SegmentTree(long[] arr, int n) {
this.n = n;
st = new long[4 * n];
lazy = new long[4 * n];
construct(arr, 0, n - 1, 0);
}
public long construct(long[] arr, int si, int ei, int node) {
if (si == ei) {
st[node] = arr[si];
return arr[si];
}
int mid = (si + ei) / 2;
long left = construct(arr, si, mid, 2 * node + 1);
long right = construct(arr, mid + 1, ei, 2 * node + 2);
st[node] = left + right;
return st[node];
}
public long get(int l, int r) {
return get(0, n - 1, l, r, 0);
}
public long get(int si, int ei, int l, int r, int node) {
if (r < si || l > ei)
return 0;
if (lazy[node] != 0) {
st[node] += lazy[node] * (ei - si + 1);
if (si != ei) {
lazy[2 * node + 1] += lazy[node];
lazy[2 * node + 2] += lazy[node];
}
lazy[node] = 0;
}
if (l <= si && r >= ei)
return st[node];
int mid = (si + ei) / 2;
return get(si, mid, l, r, 2 * node + 1) + get(mid + 1, ei, l, r, 2 * node + 2);
}
public void update(int index, int value) {
update(0, n - 1, index, 0, value);
}
public void update(int si, int ei, int index, int node, int val) {
if (si == ei) {
st[node] = val;
return;
}
int mid = (si + ei) / 2;
if (index <= mid) {
update(si, mid, index, 2 * node + 1, val);
} else {
update(mid + 1, ei, index, 2 * node + 2, val);
}
st[node] = st[2 * node + 1] + st[2 * node + 2];
}
public void rangeUpdate(int l, int r, int val) {
rangeUpdate(0, n - 1, l, r, 0, val);
}
public void rangeUpdate(int si, int ei, int l, int r, int node, int val) {
if (r < si || l > ei)
return;
if (lazy[node] != 0) {
st[node] += lazy[node] * (ei - si + 1);
if (si != ei) {
lazy[2 * node + 1] += lazy[node];
lazy[2 * node + 2] += lazy[node];
}
lazy[node] = 0;
}
if (l <= si && r >= ei) {
st[node] += val * (ei - si + 1);
if (si != ei) {
lazy[2 * node + 1] += val;
lazy[2 * node + 2] += val;
}
return;
}
int mid = (si + ei) / 2;
rangeUpdate(si, mid, l, r, 2 * node + 1, val);
rangeUpdate(mid + 1, ei, l, r, 2 * node + 2, val);
st[node] = st[2 * node + 1] + st[2 * node + 2];
}
}
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader() {
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public Reader(String file_name) throws IOException {
din = new DataInputStream(
new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException {
byte[] buf = new byte[64]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n') {
if (cnt != 0) {
break;
} else {
continue;
}
}
buf[cnt++] = (byte)c;
}
return new String(buf, 0, cnt);
}
public int nextInt() throws IOException {
int ret = 0;
byte c = read();
while (c <= ' ') {
c = read();
}
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long nextLong() throws IOException {
long ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double nextDouble() throws IOException {
double ret = 0, div = 1;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg)
return -ret;
return ret;
}
private void fillBuffer() throws IOException {
bytesRead = din.read(buffer, bufferPointer = 0,
BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read() throws IOException {
if (bufferPointer == bytesRead)
fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException {
if (din == null)
return;
din.close();
}
}
public static void main(String[] args) throws IOException {
if (System.getProperty("ONLINE_JUDGE") == null) {
try {
System.setIn(new FileInputStream(new File("input.txt")));
System.setOut(new PrintStream(new File("output.txt")));
} catch (Exception e) {
}
}
Reader sc = new Reader();
int tc = sc.nextInt();
StringBuilder sb = new StringBuilder();
while (tc-- > 0) {
long n = sc.nextLong();
long m = sc.nextLong();
sb.append("-" + (n * n) + " " + (m * m));
sb.append("\n");
}
System.out.println(sb);
}
public static boolean isEqual(HashMap<Integer, Integer> a, HashMap<Integer, Integer> b) {
if (a.size() != b.size())
return false;
for (int key : a.keySet())
if (a.getOrDefault(key, 0) != b.getOrDefault(key, 0))
return false;
return true;
}
public static double digit(long num) {
return Math.floor(Math.log10(num) + 1);
}
public static int count(ArrayList<Integer> al, int num) {
if (al.get(al.size() - 1) == num)
return 0;
int k = al.get(al.size() - 1);
ArrayList<Integer> temp = new ArrayList<>();
for (int i = 0; i < al.size(); i++) {
if (al.get(i) > k)
temp.add(al.get(i));
}
return 1 + count(temp, num);
}
public static String Util(String s) {
for (int i = s.length() - 1; i >= 1; i--) {
int l = s.charAt(i - 1) - '0';
int r = s.charAt(i) - '0';
if (l + r >= 10) {
return s.substring(0, i - 1) + (l + r) + s.substring(i + 1);
}
}
int l = s.charAt(0) - '0';
int r = s.charAt(1) - '0';
return (l + r) + s.substring(2);
}
public static boolean isPos(int idx, long[] arr, long[] diff) {
if (idx == 0) {
for (int i = 0; i <= Math.min(arr[0], arr[1]); i++) {
diff[idx] = i;
arr[0] -= i;
arr[1] -= i;
if (isPos(idx + 1, arr, diff)) {
return true;
}
arr[0] += i;
arr[1] += i;
}
} else if (idx == 1) {
if (arr[2] - arr[1] >= 0) {
long k = arr[1];
diff[idx] = k;
arr[1] = 0;
arr[2] -= k;
if (isPos(idx + 1, arr, diff)) {
return true;
}
arr[1] = k;
arr[2] += k;
} else
return false;
} else {
if (arr[2] == arr[0] && arr[1] == 0) {
diff[2] = arr[2];
return true;
} else {
return false;
}
}
return false;
}
public static boolean isPal(String s) {
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) != s.charAt(s.length() - 1 - i))
return false;
}
return true;
}
static int upperBound(ArrayList<Long> arr, long key) {
int mid, N = arr.size();
// Initialise starting index and
// ending index
int low = 0;
int high = N;
// Till low is less than high
while (low < high && low != N) {
// Find the index of the middle element
mid = low + (high - low) / 2;
// If key is greater than or equal
// to arr[mid], then find in
// right subarray
if (key >= arr.get(mid)) {
low = mid + 1;
}
// If key is less than arr[mid]
// then find in left subarray
else {
high = mid;
}
}
// If key is greater than last element which is
// array[n-1] then upper bound
// does not exists in the array
return low;
}
static int lowerBound(ArrayList<Long> array, long key) {
// Initialize starting index and
// ending index
int low = 0, high = array.size();
int mid;
// Till high does not crosses low
while (low < high) {
// Find the index of the middle element
mid = low + (high - low) / 2;
// If key is less than or equal
// to array[mid], then find in
// left subarray
if (key <= array.get(mid)) {
high = mid;
}
// If key is greater than array[mid],
// then find in right subarray
else {
low = mid + 1;
}
}
// If key is greater than last element which is
// array[n-1] then lower bound
// does not exists in the array
if (low < array.size() && array.get(low) < key) {
low++;
}
// Returning the lower_bound index
return low;
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 85b1e578dea8f2c5a762402a98600b25 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
import java.io.*;
public class MathematicalAddition {
static PrintWriter pw;
static Scanner sc;
public static void main(String[] args) throws IOException{
sc = new Scanner(System.in);
pw = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-- > 0){
long u = sc.nextLong() , v = sc.nextLong();
long x = (-1) * (u*u) , y = (v*v);
pw.println(x+" "+y);
}
pw.flush();
}
static class Scanner {
BufferedReader br;
StringTokenizer st;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(FileReader f) {
br = new BufferedReader(f);
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public double nextDouble() throws IOException {
return Double.parseDouble(next());
}
public int[] nextIntArr(int n) throws IOException {
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(next());
}
return arr;
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | a7ee077a1ee058d3d439e4263caab0b6 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.math.BigInteger;
import java.util.Scanner;
public class MathematicalAddition {
public static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int tc = scanner.nextInt();
while (tc-->0){
BigInteger u = scanner.nextBigInteger();
BigInteger v = scanner.nextBigInteger();
BigInteger a = u.pow(2);
BigInteger y = v.pow(2);
BigInteger x = a.negate();
System.out.println(x + " " + y);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | e2ab86cd84312f7670b0a95ae4e18333 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes |
import java.util.*;
public class Main{
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0) {
long u=sc.nextInt();
long v=sc.nextInt();
System.out.println(-(u*u)+" "+(v*v));
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | adfd7296e08fc8b1d6a48acf2a258405 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution{
static PrintWriter out = new PrintWriter(System.out);
static int mod = 1000000009;
public static void main(String[] args) throws IOException {
FastReader fs = new FastReader();
int t = fs.nextInt();
while(t > 0){
long u = fs.nextLong();
long v = fs.nextLong();
long x = -u * u;
long y = v * v;
out.println(x + " " + y);
t--;
}
out.flush();
}
static String rvr(String s){
StringBuilder sb = new StringBuilder(s);
sb.reverse();
return sb.toString();
}
static void op(int[] a, int n){
int max = Integer.MIN_VALUE;
for(int i = 0; i < n; i++){
max = Math.max(max, a[i]);
}
for(int i = 0; i < n; i++){
a[i] = max - a[i];
}
}
static int isCs(String x, String y, int n, int m, int[][] dp){
if(n == 0 || m == 0){
return 0;
}
if(dp[n-1][m-1] != 0) {return dp[n-1][m-1];}
if(x.charAt(n-1) == y.charAt(m-1)){
return dp[n-1][m-1] = isCs(x, y, n-1, m-1, dp) + 1;
}else{
return dp[n-1][m-1] = Math.max(isCs(x, y, n-1, m, dp), isCs(x, y, n, m-1, dp));
}
}
static int binarySearch(int[] a){
int n = a.length;
return 0;
}
static boolean distinct(String s){
for(int i = 0; i < s.length()-1; i++){
for(int j = i+1; j < s.length(); j++){
if(s.charAt(i) == s.charAt(j)){
return false;
}
}
}
return true;
}
static long sumOfDigit(long n){
long sum = 0;
while(n > 0){
long rem = n % 10;
sum += rem;
n = n / 10;
}
return sum;
}
static void swap(int a, int b){
int temp = a;
a = b;
b = temp;
}
static int[] numArr(int n){
int len = countDigit(n);
int[] a = new int[len];
int i = 0;
while(i < len){
a[i] = n % 10;
n = n / 10;
i++;
}
return a;
}
static void lcs(String X, String Y, int m, int n, int temp)
{
int[][] L = new int[m+1][n+1];
// Following steps build L[m+1][n+1] in bottom up fashion. Note
// that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1]
for (int i=0; i<=m; i++)
{
for (int j=0; j<=n; j++)
{
if (i == 0 || j == 0)
L[i][j] = 0;
else if (X.charAt(i-1) == Y.charAt(j-1))
L[i][j] = L[i-1][j-1] + 1;
else
L[i][j] = Math.max(L[i-1][j], L[i][j-1]);
}
}
// Following code is used to print LCS
int index = L[m][n];
temp = index;
// Create a character array to store the lcs string
char[] lcs = new char[index+1];
lcs[index] = '\u0000'; // Set the terminating character
// Start from the right-most-bottom-most corner and
// one by one store characters in lcs[]
int i = m;
int j = n;
while (i > 0 && j > 0)
{
// If current character in X[] and Y are same, then
// current character is part of LCS
if (X.charAt(i-1) == Y.charAt(j-1))
{
// Put current character in result
lcs[index-1] = X.charAt(i-1);
// reduce values of i, j and index
i--;
j--;
index--;
}
// If not same, then find the larger of two and
// go in the direction of larger value
else if (L[i-1][j] > L[i][j-1])
i--;
else
j--;
}
for(int k=0;k<=temp;k++)
System.out.print(lcs[k]);
}
static void sortDe(int[] a) {
ArrayList<Integer> l = new ArrayList<>();
for (int i : a)
l.add(i);
Collections.sort(l);
int list = l.size() - 1;
for (int i = 0; i < a.length; i++)
{ a[i] = l.get(list);
list--;
}
}
static void bracket(int n){
for(int i = 0; i < n; i++){
out.print("(");
}
for(int i = 0; i < n; i++){
out.print(")");
}
}
static int countDigit(int n){
return (int) Math.floor(Math.log10(n)) + 1;
}
static int countDigit(long n){
return (int) Math.floor(Math.log10(n)) + 1;
}
static void print(int[] ar){
for(int i = 0; i < ar.length; i++){
out.print(ar[i] + " ");
}
}
static long countEven(long n){
long c = 0;
long rem = 0;
while(n > 1){
rem = n % 10;
if(rem % 2 == 0){
c++;
}
n = n / 10;
}
return c;
}
static boolean divisor(long n){
int count = 2;
for(int i = 2; i*i <= n; i++){
if(n % i == 0){
count++;
}
if(count < 3){
break;
}
}
if(count == 3){return true;}
else{return false;}
}
static String reverseString(String s){
int j = s.length() - 1;
String st = new String();
while(j >= 0){
st += s.charAt(j);
j--;
}
return st;
}
static boolean isPallindrome(String s){
int i = 0, j = s.length() - 1;
while(i < j){
if(s.charAt(i) != s.charAt(j)){
return false;
}
i++;
j--;
}
return true;
}
static boolean lcsPallindrom(String s){
int i = 0, j = s.length()-1;
while(i < j){
if(s.charAt(i) != s.charAt(j)){
return false;
}
i++;
j--;
}
return true;
}
static int[] nprimeNumbers(int n){
int[] mark = new int[n+1];
Arrays.fill(mark, 1);
mark[0] = 0;
mark[1] = 0;
for(int i = 2; i < mark.length; i++){
if(mark[i] == 1){
for(int j = i*i; j < mark.length; j += i){
mark[j] = 0;
}
}
}
return mark;
}
static long gcd(long a, long b){
if(b > a){return gcd(b, a);}
if(b == 0){return a;}
return gcd(b, a % b);
}
static int gcd(int a, int b){
if(b > a){return gcd(b, a);}
if(b == 0){return a;}
return gcd(b, a % b);
}
static class Pair {
int lvl;
int str;
Pair(int lvl, int str){
this.lvl = lvl;
this.str = str;
}
}
static class lvlcompare implements Comparator<Pair> {
public int compare(Pair p1, Pair p2){
if(p1.lvl == p2.lvl){
return 0;
}else if(p1.lvl > p2.lvl){
return 1;
}else {
return -1;
}
}
}
static long count(long n){
long ct = 0;
while(n > 0){
n = n / 10;
ct++;
}
return ct;
}
static void sort(int[] a) {
ArrayList<Integer> l = new ArrayList<>();
for (int i : a)
l.add(i);
Collections.sort(l);
for (int i = 0; i < a.length; i++)
a[i] = l.get(i);
}
static void sort(long[] a) {
ArrayList<Long> l = new ArrayList<>();
for (long i : a)
l.add(i);
Collections.sort(l);
for (int i = 0; i < a.length; i++) a[i] = l.get(i);
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{br = new BufferedReader(new InputStreamReader(System.in));}
String next()
{ while (st == null || !st.hasMoreElements()) {
try {st = new StringTokenizer(br.readLine());}
catch (IOException e) {e.printStackTrace();}}
return st.nextToken();}
int nextInt() {return Integer.parseInt(next());}
long nextLong() {return Long.parseLong(next());}
double nextDouble(){return Double.parseDouble(next());}
String nextLine()
{ String str = "";
try {str = br.readLine();}
catch (IOException e) {e.printStackTrace();}
return str;
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | af7ef04350f555a8b7e8e72c50496771 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
//import static com.sun.tools.javac.jvm.ByteCodes.swap;
public class fastTemp {
static FastScanner fs = null;
static int bit[][];
static int c1;
static int c2;
public static void main(String[] args) {
fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int t = fs.nextInt();
while (t-- > 0) {
long x = fs.nextLong();
long y = fs.nextLong();
System.out.println("-"+(x*x)+" "+(y*y));
}
}
public static void solve1(int i,int c1){
for(int j=0;j < bit.length;j++){
if(j==c1){
bit[j][i] = 1;
}else{
bit[j][i] = 0;
}
}
}
public static void solve30(int i,int c2){
for(int j=0;j< bit.length;j++){
// if(j>=c2 || j>=bit.length-2){
// bit[j][i] = 1;
// }else{
bit[j][i] = 1;
// }
}}
public static void solve0(int i,int c2){
int val = bit.length/18;
for(int j=0;j< bit.length;j++){
if(j==c2 && j<bit.length-1){
bit[j][i] = 1;
bit[j+1][i] = 1;
j += 1;
}else{
bit[j][i] = 0;
}
}}
public static void union(int a,int b,int rank[],int [] p){
int x = get(a,rank,p);
int y = get(b,rank,p);
if(rank[x]==rank[y]){
rank[x]++;
}
if(rank[x]>rank[y]){
p[y] = x;
}else{
p[x] = y;
}
}
public static int get(int a,int [] rank,int []p){
return p[a] = (p[a]==a)? a : get(p[a],rank,p);
}
public static long[] sort(long arr[]) {
List<Long> list = new ArrayList<>();
for(long i:arr)
list.add(i);
Collections.sort(list);
for(int i = 0;i<list.size();i++) {
arr[i] = list.get(i);
}
return arr;
}
static class p {
int id;
int id1;
p(int id,int id1){
this.id=id;
this.id1=id1;
}
}
static long power(long x, long y, long p)
{
// Initialize result
long res = 1;
// Update x if it is more than or
// equal to p
x = x % p;
while (y > 0) {
// If y is odd, multiply x
// with result
if (y % 2 == 1)
res = (res * x) % p;
// y must be even now
y = y >> 1; // y = y/2
x = (x * x) % p;
}
return res;
}
// Returns n^(-1) mod p
static long modInverse(long n, long p)
{
return power(n, p - 2, p);
}
// Returns nCr % p using Fermat's
// little theorem.
static long nCrModPFermat(long n, long r, long p)
{
if (n<r)
return 0;
// Base case
if (r == 0)
return 1;
// Fill factorial array so that we
// can find all factorial of r, n
// and n-r
long[] fac = new long[(int)n + 1];
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % p;
return (fac[(int)n] * modInverse(fac[(int)r], p) % p * modInverse(fac[(int)n - (int)r], p) % p) % p;
}
//public static int dijkstra(int src , int dist[] ){
//
//PriorityQueue<Pair> q = new PriorityQueue<>();
//q.add(new Pair(1,0));
//
//while(q.size()>0){
//
// Pair rem = q.remove();
// for(Pair x:graph[rem.y]){
// if(dist[x.y]>dist[rem.y]+x.wt){
// dist[x.y] = dist[rem.y] + x.wt;
// q.add(new Pair(x.y,dist[x.y]));
// }
// }
//
//}
//
//return dist[dist.length-1];
//
//}
// T --> O(n) && S--> O(d)
public static int lower(long arr[], long key) {
int l = 0, r = arr.length-1;
long ans = -1;
while(l<=r) {
int mid = l +(r-l)/2;
if(arr[mid]<=key) {
ans = arr[mid];
l = mid+1;
}
else {
r = mid-1;
}
}
return l;
}
public static long upper(long arr[], long key) {
int l = 0, r = arr.length-1;
long ans = -1;
while(l<=r) {
int mid = l +(r-l)/2;
if(arr[mid] >= key) {
ans = arr[mid];
r = mid-1;
}
else {
l = mid+1;
}
}
return ans;
}
public static class String1 implements Comparable<String1>{
String str;
int id;
String1(String str , int id){
this.str = str;
this.id = id;
}
public int compareTo(String1 o){
int i=0;
while(i<str.length() && str.charAt(i)==o.str.charAt(i)){
i++;
}
if(i<str.length()){
if(i%2==1){
return o.str.compareTo(str); // descending order
}else{
return str.compareTo(o.str); // ascending order
}
}
return str.compareTo(o.str);
}
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
// ------------------------------------------swap----------------------------------------------------------------------
static void swap(int arr[],int i,int j)
{
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
//-------------------------------------------seiveOfEratosthenes----------------------------------------------------
static boolean prime[];
static void sieveOfEratosthenes(int n)
{
// Create a boolean array
// "prime[0..n]" and
// initialize all entries
// it as true. A value in
// prime[i] will finally be
// false if i is Not a
// prime, else true.
prime= new boolean[n + 1];
for (int i = 0; i <= n; i++)
prime[i] = true;
for (int p = 2; p * p <= n; p++)
{
// If prime[p] is not changed, then it is a
// prime
if (prime[p] == true)
{
// Update all multiples of p
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
// Print all prime numbers
// for (int i = 2; i <= n; i++)
// {
// if (prime[i] == true)
// System.out.print(i + " ");
// }
}
//------------------------------------------- power------------------------------------------------------------------
public static long power(int a , int b) {
if (b == 0) {
return 1;
} else if (b == 1) {
return a;
} else {
long R = power(a, b / 2);
if (b % 2 != 0) {
return (((power(a, b / 2))) * a * ((power(a, b / 2))));
} else {
return ((power(a, b / 2))) * ((power(a, b / 2)));
}
}
}
public static int log2(int x) {
return (int) (Math.log(x) / Math.log(2));
}
//---------------------------------------EXTENDED EUCLID ALGO--------------------------------------------------------
// public static class Pair{
// int x;
// int y;
// public Pair(int x,int y){
// this.x = x;
// this.y = y ;
// }
// }
// public static Pair Euclid(int a,int b){
//
// if(b==0){
// return new Pair(1,0); // answer of x and y
// }
//
// Pair dash = Euclid(b,a%b);
//
// return new Pair(dash.y , dash.x - (a/b)*dash.y);
//
//
// }
//--------------------------------GCD------------------GCD-----------GCD--------------------------------------------
public static long gcd(long a,long b){
if(b==0){
return a;
}
return gcd(b,a%b);
}
public static void BFS(ArrayList<Integer>[] graph) {
}
// This is an extension of method 2. Instead of moving one by one, divide the array in different sets
//where number of sets is equal to GCD of n and d and move the elements within sets.
//If GCD is 1 as is for the above example array (n = 7 and d =2), then elements will be moved within one set only, we just start with temp = arr[0] and keep moving arr[I+d] to arr[I] and finally store temp at the right place.
//Here is an example for n =12 and d = 3. GCD is 3 and
// void leftRotate(int arr[], int d, int n)
// {
// /* To handle if d >= n */
// d = d % n;
// int i, j, k, temp;
// int g_c_d = gcd(d, n);
// for (i = 0; i < g_c_d; i++) {
// /* move i-th values of blocks */
// temp = arr[i];
// j = i;
// while (true) {
// k = j + d;
// if (k >= n)
// k = k - n;
// if (k == i)
// break;
// arr[j] = arr[k];
// j = k;
// }
// arr[j] = temp;
// }
// }
}
// Fenwick / BinaryIndexed Tree USE IT - FenwickTree ft1=new FenwickTree(n);
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | db338686f5d1c1fe0d01f95d4f8e04f3 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int t= sc.nextInt();
for(int T=0;T<t;T++){
long u=sc.nextInt();
long v=sc.nextInt();
System.out.println((u*u)+" "+(v*v*-1));
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | d8467e5622781281bd62acf8aae867df | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
public class mathematical{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
long x=sc.nextLong();
long y=sc.nextLong();
System.out.println(-(x*x)+" "+y*y);
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | ca723aebd7c5ef44ca5d114d6df2a228 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.*;
public class cf {
public static void main(String[] args){
FastScanner sc = new FastScanner();
int z = sc.nextInt();
//int z=1;
while(z-- > 0){
/*int n=sc.nextInt();
//int m=sc.nextInt();
int arr[]=new int[n];
for(int i=0;i<n;i++){
arr[i]=sc.nextInt();
}*/
/*int a=sc.nextInt();
int b=sc.nextInt();
int q=sc.nextInt();
boolean []aa=new boolean[a+1];
boolean []bb=new boolean[b+1];
for(int i=1;i<=a;i++){
if(a%i==0){
aa[i]=true;
}
}
for(int i=1;i<=b;i++){
if(b%i==0){
bb[i]=true;
}
}
for(int i=0;i<q;i++){
boolean ch=false;
int low=sc.nextInt();
int high=sc.nextInt();
for(int j=high;j>=low;j--){
if(j<=a && aa[j]==true){
if(j<=b && bb[j]==true){
System.out.println(j);
ch=true;
break;
}
}
}
if(ch==false){
System.out.println(-1);
}
}*/
int x=sc.nextInt();
int y=sc.nextInt();
long ansx=1l*x*x;
long ansy=1l*y*y;
System.out.println(-ansx+" "+ansy);
}
}
}
/////////////////////////////////////////////////////////////
//BINARY SEARCH
/*Arrays.binarySearch(arr,key);
if key--> present
return index
else
return -(index where it would be inserted)-1*/
//////////////////////////////////////////////////////////////
/* VALUE JUST GREATER THAN X
find_min(int[]arr,int x){
int l=-1;
int r=arr.length;
while(r>l+1){
int mid=(l+r)/2;
if(arr[mid]<x){
l=mid;
}
else{
r=mid;
}
}
return r;
}
VALUE JUST SMALLER THAN X
find_max(int[]arr,int x){
int l=-1;
int r=arr.length;
while(r>l+1){
int mid=(l+r)/2;
if(arr[mid]<=x){
l=mid;
}
else{
r=mid;
}
}
return l;
}
*/
//////////////////////////////////////////////////////////////
// LCM AND GCD
/*
public static int gcd(int a,int b){
if(b == 0){
return a;
}
return gcd(b,a%b);
}
public static int lcm(int a,int b){
return (a / gcd(a, b)) * b;
}*/
///////////////////////////////////////////////////////////////////////////////////
//Iterator
/*Iterator iterator = object.iterator();
while (iterator.hasNext()) {
System.out.print(iterator.next() + " ");
}*/
///////////////////////////////////////////////////////////////////////////////////
class FastScanner
{
//I don't understand how this works lmao
private int BS = 1 << 16;
private char NC = (char) 0;
private byte[] buf = new byte[BS];
private int bId = 0, size = 0;
private char c = NC;
private double cnt = 1;
private BufferedInputStream in;
public FastScanner() {
in = new BufferedInputStream(System.in, BS);
}
public FastScanner(String s) {
try {
in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
} catch (Exception e) {
in = new BufferedInputStream(System.in, BS);
}
}
public char getChar() {
while (bId == size) {
try {
size = in.read(buf);
} catch (Exception e) {
return NC;
}
if (size == -1) return NC;
bId = 0;
}
return (char) buf[bId++];
}
public int nextInt() {
return (int) nextLong();
}
public int[] nextInts(int N) {
int[] res = new int[N];
for (int i = 0; i < N; i++) {
res[i] = (int) nextLong();
}
return res;
}
public long[] nextLongs(int N) {
long[] res = new long[N];
for (int i = 0; i < N; i++) {
res[i] = nextLong();
}
return res;
}
public long nextLong() {
cnt = 1;
boolean neg = false;
if (c == NC) c = getChar();
for (; (c < '0' || c > '9'); c = getChar()) {
if (c == '-') neg = true;
}
long res = 0;
for (; c >= '0' && c <= '9'; c = getChar()) {
res = (res << 3) + (res << 1) + c - '0';
cnt *= 10;
}
return neg ? -res : res;
}
public double nextDouble() {
double cur = nextLong();
return c != '.' ? cur : cur + nextLong() / cnt;
}
public double[] nextDoubles(int N) {
double[] res = new double[N];
for (int i = 0; i < N; i++) {
res[i] = nextDouble();
}
return res;
}
public String next() {
StringBuilder res = new StringBuilder();
while (c <= 32) c = getChar();
while (c > 32) {
res.append(c);
c = getChar();
}
return res.toString();
}
public String nextLine() {
StringBuilder res = new StringBuilder();
while (c <= 32) c = getChar();
while (c != '\n') {
res.append(c);
c = getChar();
}
return res.toString();
}
public boolean hasNext() {
if (c > 32) return true;
while (true) {
c = getChar();
if (c == NC) return false;
else if (c > 32) return true;
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 36c58ebf925d0820d76a557bdac55827 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args) {
FastReader a = new FastReader();
int test = a.nextInt();
while (test-- > 0) {
long num1 = a.nextInt();
long num2 = a.nextInt();
long ans1 = num1*num1;
long ans2 = num2*num2;
System.out.println(-ans1+" "+ans2);
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 952586517d4193f8275eb9aaac4f8c50 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
import java.io.*;
public class Codechef
{
public static void main(String []args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
long u = sc.nextInt();
long v = sc.nextInt();
long ans = -(u*u);
long ans1 = v*v;
System.out.println(ans + " "+ ans1);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 71ac27f97dabb1d9ba9d7614d4f2250d | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
/**
*
* @author h
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while(n-->0){
long u = sc.nextInt();
long v = sc.nextInt();
System.out.print(-(u*u)+ " ");
System.out.println(v*v);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | f32e513ab94d66188d243775ea45c1f0 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.math.BigInteger;
public class MathAddition{
public static void main (String[] args) throws Exception{
//if u = 3, v = 5, x = 9 y = -25
// conclude that x = u^2, y = -v^2
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
for(int i = 0; i < t; i++){
String[] input = br.readLine().split(" ");
int u = Integer.parseInt(input[0]);
int v = Integer.parseInt(input[1]);
BigInteger x = BigInteger.valueOf(u).pow(2);
BigInteger y = BigInteger.valueOf(v).pow(2);
System.out.println(x + " " + y.negate());
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 359256dcdaf83ca4b2aac273798edf25 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
// write your code here
PrintWriter out = new PrintWriter(System.out);
FastReader scan = new FastReader();
Task solver = new Task();
solver.solve(1,scan,out);
out.close();
}
static class Task{
public void solve(int testNumber, FastReader scan, PrintWriter out) {
int [][] L = {{1,3,3,4,5,5,6},{2,2,4,1,1,4,2}};
/*Pattern pattern = Pattern.compile("[B]+"); //REGEX template
Matcher matcher = pattern.matcher(s);*/
int t=1;
t = scan.nextInt();
for(int i=0; i<t;i++){
long n = scan.nextLong();
ArrayList<Integer> list = new ArrayList<>();
ArrayList<Integer> list2 = new ArrayList<>();
long m = scan.nextLong();
long a = (n+m)*n-n*m;
long b = n*m-(n+m)*m;
out.println(a+" "+b);
}
}
public static String parenthesys(int n){
String answer = "";
for(int j = 0; j<n;j++){
answer+="(";
}
for(int j = 0; j<n;j++){
answer+=")";
}
return answer;
}
public static long digitsSum(long n){
long sum=0;
while(n!=0){
sum+=n%10;
n=n/10;
}
return sum;
}
public static boolean isFibonachi(int n){
int f1=1;
int f2=1;
while(f2<=n){
if(f2==n){
return true;
}
int temp = f1+f2;
f1=f2;
f2=temp;
}
return false;
}
public static boolean isValid(int x, int y, int n){
if(x<0 || y<0 || x>=n || y>=n){
return false;
}
return true;
}
public static int factorial(int n){
if(n<=1){
return 1;
}else{
return n*factorial(n-1);
}
}
public static int DBD(int a, int b){
if (b==0) return a;
return DBD(b,a%b);
}
public static boolean isPrime(int n){
if(n<2){
return false;
}
for(int i=2; i<Math.sqrt(n)+1 ;i++){
if(n%i==0){
return false;
}
}
return true;
}
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
public FastReader(String s) throws FileNotFoundException {
br = new BufferedReader(new FileReader(new File(s)));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 0f3da9b8470e6ff8401d86a5f1d69eeb | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.*;
public class Mathematical_Addition{
public static void main(String[] args) throws IOException{
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
for(int i = 0; i<N; i++){
long a = sc.nextInt();
long b = sc.nextInt();
String ans = Long.toString(0-a*a) + " " + Long.toString(b*b);
System.out.println(ans);
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | e9fededba9bc580e5891909e205c53b8 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
import java.io.*;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = sc.nextInt();
for (; t > 0; t--) {
long u = sc.nextLong(); long v = sc.nextLong();
long x = u*u;
long y = -v*v;
out.printf("%s %s\n", x, y);
}
out.close();
sc.close();
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 79dcb6985d3452f52c4f1945719ddca3 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for (int i = 0; i < t; i++) {
long u = in.nextInt();
long v = in.nextInt();
long x = u * u;
long y = -v * v;
System.out.println(x + " " + y);
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | b2b14e2924d09b5b675d13d15b3f3f69 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
import java.io.*;
public class A {
public static void main(String[] args) throws IOException {
FastReader in = new FastReader(System.in);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
int t = in.nextInt();
for (int tt = 0; tt < t; tt++) {
long u = in.nextLong();
long v = in.nextLong();
long x = -1 * ((binaryExponentiation(u, 2)));
long y = ((binaryExponentiation(v, 2)));
pw.println(x + " " + y);
}
pw.close();
}
static boolean checkPalindrome(String str) {
int len = str.length();
for (int i = 0; i < len / 2; i++) {
if (str.charAt(i) !=
str.charAt(len - i - 1))
return false;
}
return true;
}
public static boolean isSorted(int[] arr) {
for (int i = 1; i < arr.length; i++)
if (arr[i] < arr[i - 1]) return false;
return true;
}
static long binaryExponentiation(long x, long n) {
if (n == 0) return 1;
else if (n % 2 == 0) return binaryExponentiation(x * x, n / 2);
else return x * binaryExponentiation(x * x, (n - 1) / 2);
}
public static void Sort(int[] a) {
ArrayList<Integer> lst = new ArrayList<>();
for (int i : a) lst.add(i);
Collections.sort(lst);
for (int i = 0; i < lst.size(); i++) a[i] = lst.get(i);
}
static void debug(Object... obj) {
System.err.println(Arrays.deepToString(obj));
}
static class FastReader {
InputStream is;
private byte[] inbuf = new byte[1024];
private int lenbuf = 0, ptrbuf = 0;
public FastReader(InputStream is) {
this.is = is;
}
public int readByte() {
if (lenbuf == -1) throw new InputMismatchException();
if (ptrbuf >= lenbuf) {
ptrbuf = 0;
try {
lenbuf = is.read(inbuf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (lenbuf <= 0) return -1;
}
return inbuf[ptrbuf++];
}
public boolean isSpaceChar(int c) {
return !(c >= 33 && c <= 126);
}
private boolean isEndOfLine(int c) {
return c == '\n' || c == '\r' || c == -1;
}
public int skip() {
int b;
while ((b = readByte()) != -1 && isSpaceChar(b)) ;
return b;
}
public String next() {
int b = skip();
StringBuilder sb = new StringBuilder();
while (!(isSpaceChar(b))) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public String nextLine() {
int c = skip();
StringBuilder sb = new StringBuilder();
while (!isEndOfLine(c)) {
sb.appendCodePoint(c);
c = readByte();
}
return sb.toString();
}
public int nextInt() {
int num = 0, b;
boolean minus = false;
while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
if (b == '-') {
minus = true;
b = readByte();
}
while (true) {
if (b >= '0' && b <= '9') {
num = (num << 3) + (num << 1) + (b - '0');
} else {
return minus ? -num : num;
}
b = readByte();
}
}
public long nextLong() {
long num = 0;
int b;
boolean minus = false;
while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
if (b == '-') {
minus = true;
b = readByte();
}
while (true) {
if (b >= '0' && b <= '9') {
num = (num << 3) + (num << 1) + (b - '0');
} else {
return minus ? -num : num;
}
b = readByte();
}
}
public double nextDouble() {
return Double.parseDouble(next());
}
public char[] next(int n) {
char[] buf = new char[n];
int b = skip(), p = 0;
while (p < n && !(isSpaceChar(b))) {
buf[p++] = (char) b;
b = readByte();
}
return n == p ? buf : Arrays.copyOf(buf, p);
}
public char readChar() {
return (char) skip();
}
public long[] readArrayL(int n) {
long[] arr = new long[n];
for (int i = 0; i < n; i++) arr[i] = nextLong();
return arr;
}
public int[] readArray(int n) {
int[] arr = new int[n];
for (int i = 0; i < n; i++) arr[i] = nextInt();
return arr;
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 3eaca5d11a50fb8765f741bd47a88600 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.*;
public class Main2 {
static long mod = 998244353;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int test = in.nextInt();
for(int t = 1; t<=test;t++) {
long u =in.nextLong(), v = in.nextLong();
pw.println((-1)*(u*u)+" "+(v*v));
}
pw.close();
}
static void debug(Object... obj) {
System.err.println(Arrays.deepToString(obj));
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 3e21baf145b0497d3b82a7cd77d77fac | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static void main (String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
int tests = Integer.parseInt(in.readLine());
while(tests-->0) {
long[] values = new long[2];
StringTokenizer st = new StringTokenizer(in.readLine());
for(int i = 0; i < values.length; i++) {
values[i] = Long.parseLong(st.nextToken());
}
long u = values[0], v = values[1];
out.write(-(u*u) + " " + (v*v));
out.newLine();
}
out.flush();
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 2d21b725e10b06c5067f95d8e0cd9d96 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class A1584 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int T = in.nextInt();
for (int t=0; t<T; t++) {
long u = in.nextInt();
long v = in.nextInt();
System.out.println(u*u + " " + (-v*v));
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 3d468fac1ccf44cfbda2df6e29b85bdb | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.*;
public class Test {
public static void main(String[] args) throws IOException {
Reader rd = new Reader();
int t = rd.nextInt();
while (t-- > 0) {
long u = rd.nextLong();
long v = rd.nextLong();
System.out.println("-" + (u * u) + " " + (v * v));
}
rd.close();
}
private static int search(int[] arr, int elementToBeSearched) {
int beg = 0, end = arr.length - 1, mid = (beg + end) / 2;
while (beg <= end && arr[mid] != elementToBeSearched) {
if (elementToBeSearched < arr[mid]) {
end = mid - 1;
} else if (elementToBeSearched > arr[mid]) {
beg = mid + 1;
}
mid = (beg + end) / 2;
}
if (arr[mid] == elementToBeSearched) return mid;
return -1;
}
private static void solve() {
}
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader() {
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public Reader(String file_name) throws IOException {
din = new DataInputStream(new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException {
byte[] buf = new byte[64]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n') {
if (cnt != 0) {
break;
} else {
continue;
}
}
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
public int nextInt() throws IOException {
int ret = 0;
byte c = read();
while (c <= ' ') {
c = read();
}
boolean neg = (c == '-');
if (neg) c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg) return -ret;
return ret;
}
public long nextLong() throws IOException {
long ret = 0;
byte c = read();
while (c <= ' ') c = read();
boolean neg = (c == '-');
if (neg) c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg) return -ret;
return ret;
}
public double nextDouble() throws IOException {
double ret = 0, div = 1;
byte c = read();
while (c <= ' ') c = read();
boolean neg = (c == '-');
if (neg) c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg) return -ret;
return ret;
}
private void fillBuffer() throws IOException {
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1) buffer[0] = -1;
}
private byte read() throws IOException {
if (bufferPointer == bytesRead) fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException {
if (din == null) return;
din.close();
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | bcb0c2eac5a646d207a7401138b6b7ac | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | /**
* A_Mathematical_Addition
*/
import java.io.*;
import java.util.*;
public class A_Mathematical_Addition {
public static void main(String[] args) {
MyScanner s = new MyScanner();
int t = s.nextInt();
for(int f = 0;f<t;f++)
{
long u = s.nextLong();
long v = s.nextLong();
System.out.println(-u*u+" "+v*v);
}
}
}
class MyScanner {
BufferedReader br; StringTokenizer st;
public MyScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine(){
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | deffca0a36237460a5846e820ff050d5 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | // Created By Jefferson Samuel on 23/08/21 at 2:11 am
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;
public class B {
static void solve() throws Exception {
int T = scanInt();
while (T-- > 0) {
long ar[] = scLoAr(2);
out.println(-(ar[0]*ar[0]) +" "+(ar[1]*ar[1]));
}
}
// Essentials
static int scanInt() throws IOException {return parseInt(scanString());}
static int[] scInAr(int N) throws IOException {
int[] a = new int[N];
for(int i = 0;i<N;i++)a[i] = scanInt();
return a;
}
static ArrayList<Integer> scInLi(int N) throws IOException
{
ArrayList<Integer> lis = new ArrayList<>(N);
for (int i = 0; i < N; i++) lis.add(scanInt());
return lis;
}
static void revsLis(ArrayList<Integer> lis) {lis.sort(Collections.reverseOrder());}
static void sortAr(int ar[]) {Arrays.sort(ar);}
static void revsortAr(int ar[]){sortAr(ar);revar(ar);}
static void revar(int ar[]){for (int i = 0; i < ar.length / 2; i++) { int temp = ar[i]; ar[i] = ar[ar.length - 1 - i]; ar[ar.length - 1 - i] = temp;}}
static long[] scLoAr(int N) throws IOException {
long[] a = new long[N];
for(int i = 0;i<N;i++)a[i] = scanLong();
return a;
}
static long scanLong() throws IOException {return parseLong(scanString());}
static String scanString() throws IOException {
while (tok == null || !tok.hasMoreTokens()) {
tok = new StringTokenizer(in.readLine());
}
return tok.nextToken();
}
static BufferedReader in;
static PrintWriter out;
static StringTokenizer tok;
public static void main(String[] args) {
try {
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
solve();
in.close();
out.close();
} catch (Throwable e) {
e.printStackTrace();
exit(1);
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | f36274d2673895ca75ba6cfa70138618 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | //import com.sun.security.jgss.GSSUtil;
import java.util.Scanner;
public class forces {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
while (t-- > 0) {
int u = scanner.nextInt();
int v = scanner.nextInt();
long x = (long) -1 * u * u;
long y = (long) v*v;
System.out.println(x+" "+y);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | ea6eeb2b69a9ef4d0baa527c9e3f3337 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
import java.io.*;
public class pre1{
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void main(String args[]){
FastReader obj = new FastReader();
int tc = obj.nextInt();
while(tc--!=0){
long u = obj.nextLong(),v = obj.nextLong();
System.out.println(-1*u*u+" "+v*v);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 62641188340eeb6e988e0ba92e848dee | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static void daunism1() {
}
static void dfs(int v, int w) {
}
static long gcd(long a, long b) {
if (b == 0) return Math.abs(a);
return gcd(b, a % b);
}
public static void main(String[] args) throws IOException {
// br = new BufferedReader(new FileReader("pencils.in"));
// out = new PrintWriter("pencils.out");
int t=nextInt();
for (int i = 0; i < t; i++) {
long u=nextLong();
long v=nextLong();
out.println(u*u+" "+(-v*v));
}
out.close();
}
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(System.out);
static StringTokenizer in = new StringTokenizer("");
public static boolean hasNext() throws IOException {
if (in.hasMoreTokens()) return true;
String s;
while ((s = br.readLine()) != null) {
in = new StringTokenizer(s);
if (in.hasMoreTokens()) return true;
}
return false;
}
public static String nextToken() throws IOException {
while (!in.hasMoreTokens()) {
in = new StringTokenizer(br.readLine());
}
return in.nextToken();
}
public static int nextInt() throws IOException {
return Integer.parseInt(nextToken());
}
public static long nextLong() throws IOException {
return Long.parseLong(nextToken());
}
public static double nextDouble() throws IOException {
return Double.parseDouble(nextToken());
}
static class Maincraft implements Comparable<Maincraft> {
int x;
int y;
public Maincraft(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public int compareTo(Maincraft o) {
return Integer.compare(x, o.x);
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 80075d9ed29e67c24cef7553aba532d8 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.io.*;
public class TestClass {
BufferedReader br;
StringTokenizer st;
public TestClass(){ // constructor
br = new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while (st == null || !st.hasMoreElements()){
try{
st = new StringTokenizer(br.readLine());
}
catch (IOException e){
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt(){
return Integer.parseInt(next());
}
long nextLong(){
return Long.parseLong(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
String nextLine(){
String str = "";
try{
str = br.readLine();
}
catch (IOException e){
e.printStackTrace();
}
return str;
}
static void sort(int[] arr){
int n = arr.length;
Random rnd = new Random();
for(int i = 0; i < n; ++i){
int tmp = arr[i];
int randomPos = i + rnd.nextInt(n - i);
arr[i] = arr[randomPos];
arr[randomPos] = tmp;
}
Arrays.sort(arr);
}
static long gcd(long a, long b) {
if(b == 0) {
return a;
}
return gcd(b, a % b);
}
//static int n;
static ArrayList<Integer> graph[];
static void addEdge(int u, int v){
graph[u].add(v);
graph[v].add(u);
}
static boolean isSafe(int r, int c, int n, int m){
if(r >= 0 && r < n && c >= 0 && c < m){
return true;
}
return false;
}
static long mod = (long)1e9 + 7;
static int dir[][] = {{1, 0}, {-1, 0}, {0 ,1}, {0, -1}};
static int par[];
static int findPar(int u) {
if(par[u] == u) {
return u;
}
return par[u] = findPar(par[u]);
}
static void merge(int p1, int p2) {
par[p1] = par[p2];
}
static class Pair {
int l;
int r;
Pair(int l, int r){
this.l = l;
this.r = r;
}
}
public static void main(String[] args) throws Exception{
TestClass in = new TestClass();
PrintWriter out = new PrintWriter(System.out);
int test = in.nextInt();
while(test-- > 0){
long u = in.nextLong();
long v = in.nextLong();
u = u*u;
v = v*v;
out.println(-u + " " + v);
}
out.flush();
out.close();
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 4aa8db67d5a20bcb95998d81223aa0fe | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Codeforces {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter writer = new PrintWriter(System.out);
int T = Integer.parseInt(br.readLine());
while(T-- > 0) {
StringTokenizer st = new StringTokenizer(br.readLine());
long u = Long.parseLong(st.nextToken());
long v = Long.parseLong(st.nextToken());
u = -1l*u*u;
v = v*v;
writer.println(u+" "+v);
}
writer.close();
br.close();
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | b1bd3816f4d703941312b2c810ab1a6b | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes |
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class Practice2 {
static int[] sort(int[] arr) {
int n=arr.length;
ArrayList<Integer> al=new ArrayList<>();
for(int i=0;i<n;i++) {
al.add(arr[i]);
}
Collections.sort(al);
for(int i=0;i<n;i++) {
arr[i]=al.get(i);
}
return arr;
}
public static void main (String[] args) {
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
// out.print();
//out.println();
FastReader sc=new FastReader();
int t=sc.nextInt();
while(t-->0) {
long x=sc.nextLong();
long y=sc.nextLong();
out.println(x*x+" "+(0-y*y));
}
out.close();
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 8350636fa4e1c1706a89a81e97aa9624 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
/**
*
* @author Acer
*/
public class MathematicalAddition {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
while(T-- > 0){
long u = sc.nextLong();
long v = sc.nextLong();
long x = u*u*(-1);
long y = v*v;
System.out.println(x+" "+y);
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 5e69f78c1614aa1b2af59e47c0a16e9b | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int tc = 0; tc < t; ++tc) {
int u = sc.nextInt();
int v = sc.nextInt();
System.out.println(solve(u, v));
}
sc.close();
}
static String solve(int u, int v) {
return String.format("%d %d", (long) u * u, -(long) v * v);
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 4e67ec7bdf79a0ceca9cbee1e0d99a09 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes |
import java.util.*;
public class SolnA {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t>0) {
t--;
long u = sc.nextLong();
long v = sc.nextLong();
long x = -u*u;
long y = v*v;
System.out.println(x+" "+y);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | a965717e43df4e3b1cd559000144a808 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
import java.io.*;
public class Omar {
static Scanner sc=new Scanner(System.in);
static PrintWriter pw=new PrintWriter(System.out);
public static void sort(int[]in) {
shuffle(in);
Arrays.sort(in);
}
public static void shuffle(int[]in) {
for(int i=0;i<in.length;i++) {
int idx=(int)(Math.random()*in.length);
int tmp=in[i];
in[i]=in[idx];
in[idx]=tmp;
}
}
public static void main(String[] args) throws IOException, InterruptedException {
int t=sc.nextInt();
while(t-->0) {
long u=sc.nextLong(),v=sc.nextLong();
pw.println(-u*u+" "+v*v);
}
pw.flush();
}
static class pair implements Comparable<pair> {
long x;
long y;
public pair(long x, long y) {
this.x = x;
this.y = y;
}
public String toString() {
return x + " " + y;
}
public boolean equals(Object o) {
if (o instanceof pair) {
pair p = (pair) o;
return p.x == x && p.y == y;
}
return false;
}
public int hashCode() {
return new Double(x).hashCode() * 31 + new Double(y).hashCode();
}
public int compareTo(pair other) {
if (this.x == other.x) {
return Long.compare(this.y, other.y);
}
return Long.compare(other.x, this.x);
}
}
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(FileReader r) {
br = new BufferedReader(r);
}
public String readAllLines(BufferedReader reader) throws IOException {
StringBuilder content = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
content.append(line);
content.append(System.lineSeparator());
}
return content.toString();
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public long[] nextlongArray(int n) throws IOException {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public Long[] nextLongArray(int n) throws IOException {
Long[] a = new Long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public int[] nextIntArray(int n) throws IOException {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public Integer[] nextIntegerArray(int n) throws IOException {
Integer[] a = new Integer[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public boolean ready() throws IOException {
return br.ready();
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | cde434c43cfa57bf35cfe1ee439c3ac1 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.*;
public class MathematicalAddition {
public static void main(String[] args) {
new MathematicalAddition().run();
}
BufferedReader br;
PrintWriter out;
long mod = (long) (1e9 + 7), inf = (long) (3e18);
class pair {
int F, S;
pair(int f, int s) {
F = f; S = s;
}
}
void solve() {
int t = ni();
while(t-- > 0) {
//TODO:
long u= nl();
long v= nl();
long x=-(u*u);
long y=v*v;
out.println(x+" "+y);
}
}
// -------- I/O Template -------------
char nc() {
return ns().charAt(0);
}
String nLine() {
try {
return br.readLine();
} catch(IOException e) {
return "-1";
}
}
double nd() {
return Double.parseDouble(ns());
}
long nl() {
return Long.parseLong(ns());
}
int ni() {
return Integer.parseInt(ns());
}
int[] na(int n) {
int a[] = new int[n];
for(int i = 0; i < n; i++) a[i] = ni();
return a;
}
StringTokenizer ip;
String ns() {
if(ip == null || !ip.hasMoreTokens()) {
try {
ip = new StringTokenizer(br.readLine());
if(ip == null || !ip.hasMoreTokens())
ip = new StringTokenizer(br.readLine());
} catch(IOException e) {
throw new InputMismatchException();
}
}
return ip.nextToken();
}
void run() {
try {
if (System.getProperty("ONLINE_JUDGE") == null) {
br = new BufferedReader(new FileReader("/media/ankanchanda/Data/WORKPLACE/DS and CP/Competitive Programming/VSCODE/IO/input.txt"));
out = new PrintWriter("/media/ankanchanda/Data/WORKPLACE/DS and CP/Competitive Programming/VSCODE/IO/output.txt");
} else {
br = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
}
} catch (FileNotFoundException e) {
System.out.println(e);
}
solve();
out.flush();
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | b72ca0feec18f2edbc10e632d582d45f | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | /* package codechef; // don't place package name! */
import java.io.*;
public final class P {
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int tt=Integer.parseInt(br.readLine()),a=0,b=0,l=0,c=0,c1=0;
long d=0,t=0,n=0;
long j=0;
for(int i=1;i<=tt;i++)
{
String arg[]=br.readLine().split(" ");
t=Long.parseLong(arg[0]);
n=Long.parseLong(arg[1]);
t=t*t;
d=n*n*(-1);
System.out.println(t+" "+d);
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | f6cd4e9c2f4a722af4a16c377216263c | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
public class MathematicalAddition {
public static void main(String[] args) throws FileNotFoundException {
FastReader in = new FastReader();
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
int t = in.nextInt();
while (t-- > 0) {
long x = in.nextLong();
long y = in.nextLong();
out.println(-x * x + " " + y * y);
}
out.close();
}
private static class FastReader {
BufferedReader br;
StringTokenizer st;
FastReader() throws FileNotFoundException {
br = new BufferedReader(new
InputStreamReader(System.getProperty("ONLINE_JUDGE") == null ? new FileInputStream("input.txt") : System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | ff8096c4e5d7abd942d6855c3679ecfb | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class A_Mathematical_Addition{
static Scanner in=new Scanner(System.in);
static int testCases;
static long u,v;
static void solve(){
System.out.println( (u*u*-1)+" "+(v*v) );
}
public static void main(String [] amit){
testCases=in.nextInt();
for(int t=0;t<testCases;t++){
u=in.nextLong();
v=in.nextLong();
solve();
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 0f945e3cd3be2bb72cbb4ba61ffed5aa | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
/* for (int i = -100; i < 100; i++) {
for (int j = -100; j < 100; j++) {
if (i == 0 || j == 0) continue;
if((i % 2) == 0 && (j % 3) == 0 && (i + j) % 5 == 0) {
int v1 = i / 2 + j / 3;
int v2 = (i + j) / 5;
if (v1 == v2) debug(i, j);
}
}
}*/
int t = in.nextInt();
for (int tt = 0; tt < t; tt++) {
long x = in.nextLong(), y = in.nextLong();
pw.println(x * (-1) * x + " " + y * y);
}
pw.close();
}
static void debug(Object... obj) {
System.err.println(Arrays.deepToString(obj));
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 8 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 325910139c749b098c30bf0c6f30443e | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | 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;
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Equations
{
public static void main(String[] args)
{
int cases;
long u,v,x,y;
Scanner sc = new Scanner(System.in);
//cases = Integer.parseInt(sc.nextLine());
cases = sc.nextInt();
for(int j=0; j<cases; j++)
{
//u = Integer.parseInt(sc.nextLine());
u = sc.nextInt();
//v = Integer.parseInt(sc.nextLine());
v = sc.nextInt();
y = v*v;
x = -(u*u);
System.out.println(x);
System.out.println(y);
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 17 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 40be6504d3a16766be2b7cc96d7e56e3 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
public class MathematicalAddition {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t > 0) {
long a = sc.nextInt();
long b = sc.nextInt();
long[] res = solve(a, b);
System.out.println(res[0] + " " + res[1]);
t--;
}
}
public static long[] solve(long a, long b) {
long[] res = new long[2];
long x = 0, y = 0;
if(a == 0 && b == 0)
return new long[]{10, 10};
x = a * a;
y = -1L * b * b;
long g = gcd(x, -1L * y);
x = x/g;
y = y/g;
return new long[]{x, y};
}
public static long gcd(long a, long b){
if (a == 0)
return b;
return gcd(b%a, a);
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 11 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | d44e935b91b87b0fb68cd7e8d25fc031 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
public class MathematicalAddition {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t > 0) {
long a = sc.nextInt();
long b = sc.nextInt();
long[] res = solve(a, b);
System.out.println(res[0] + " " + res[1]);
t--;
}
}
public static long[] solve(long a, long b) {
long[] res = new long[2];
long x = 0, y = 0;
if(a == 0 && b == 0) {
res = new long[]{10, 10};
if((long)Math.pow(a, 2) * 10 != -1L * (long)Math.pow(b, 2) * 10) {
System.out.println(x + " " + y + "wont work");
System.out.println("ahaha");
}
return res;
}
x = a * a;
y = -1L * b * b;
long g = gcd(x, -1L * y);
x = x/g;
y = y/g;
if(a * a * y != -1L * b * b * x) {
System.out.println(x + " " + y + "wont works");
}
return new long[]{x, y};
}
public static long gcd(long a, long b){
if (a == 0)
return b;
return gcd(b%a, a);
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 11 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | cc9913aa3b4dbbad4576e486d73dcab7 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String [] args){
Scanner in = new Scanner(System.in);
long veces = in.nextInt();
while(veces!=0){
long a= in.nextInt();
long b = in.nextInt();
System.out.println((a*a*-1)+" "+(b*b));
veces--;
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 11 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 89ecfc24ce5306f9e459cf91a81fe7ff | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0)
{
long u = sc.nextLong();
long v = sc.nextLong();
System.out.println(-1*u*u + " " + v*v);
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 11 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | cf1daed31609f75839cc0f1fc5ba2116 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class Mathematical {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int testCases = scanner.nextInt();
for (int i = 0; i < testCases ; i++) {
long num1 = scanner.nextInt();
long num2 = scanner.nextInt();
getSolutions(num1, num2);
}
}
public static void getSolutions(long u, long v) {
long x = 0;
long y = 0;
x = u*u;
y = v*v;
System.out.println("-" + x + " " + y);
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 11 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 20718bfb06f2f0c43e387087049b0f56 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class AMathematicalAddition {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0) {
long u = sc.nextInt();
long v = sc.nextInt();
System.out.println((u*u)+" "+(-(v*v)));
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 11 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | 06e4221371771e00f6a2c476e7d3703b | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.io.*;
import java.util.*;
/**
* -----------------|___________|---------------------
* CCCCCCCCC OOOOOOOOOO DDDDDDDD EEEEEEEEE
* CCCC OOO OOO DD DDD EEEE
* CCCC OOO OOO DD DDD EEEEEEEEEE
* CCCC OOO OOO DD DDDD EEEE
* CCCCCCCCC OOOOOOOOOO DDDDDDDDDDDD EEEEEEEEEE
* -----------------|___________|---------------------
*/
public class Main {
static long M = 1000000007;
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter sout = new PrintWriter(outputStream);
int t = in.nextInt();
while (t-- > 0) {
long a = in.nextLong();
long b = in.nextLong();
sout.println((-(long) a * a + " " + (long) b * b));
}
sout.close();
}
public static long factorial(long N) {
long result = 1;
for (long x = 2; x <= N; x++) {
result = (result * x) % M;
}
return result;
}
public static long binomial(long n) {
long nom = factorial(n); // n!
long denom = ((long) 2 * factorial(n - 2)) % M; // k!(n-k)!
return (nom * fastPow(denom, M - 2)) % M;
}
public static long fastPow(long num, long pow) {
if (pow == 0)
return 1;
if (pow % 2 == 0) {
long result = fastPow(num, pow / 2);
result = (result * result) % M;
return result;
}
long result = fastPow(num, pow - 1);
result = (result * num) % M;
return result;
}
public static void sort(long[] a) {
ArrayList<Long> l = new ArrayList<>();
for (long i : a)
l.add(i);
Collections.sort(l);
for (int i = 0; i < a.length; i++)
a[i] = l.get(i);
}
public static class Node {
int value;
boolean visit = false;
List<Node> neighbors = new ArrayList<>();
public Node(int value) {
this.value = value;
}
}
public static class InputReader {
private final BufferedReader reader;
private StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String nextToken() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(nextToken());
}
public long nextLong() {
return Long.parseLong(nextToken());
}
public double nextDouble() {
return Double.parseDouble(nextToken());
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 11 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | cafd0ea857fe63524201eaf5d6c21867 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class CF2410{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int testCases = scan.nextInt();
while(testCases>0){
long u = scan.nextInt();
long v = scan.nextInt();
System.out.println(-u*u+" "+(v*v));
testCases--;
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 11 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | f3103ca02926daa27288def7e027464d | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0) {
long a=sc.nextLong();
long b=sc.nextLong();
long x=a*a;
long y=b*b;
System.out.println(-x+" "+y);
}
sc.close();
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 11 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | fda23f551c177d294b1ce0a4d12b3d11 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
public class Main {
public static void main(String args[]) {
int t;
Scanner sc=new Scanner(System.in);
t=sc.nextInt();
while(t>0)
{
long u,v;
u=sc.nextInt();
v=sc.nextInt();
long min1;
long max1;
min1=u*u;
min1=0-min1;
max1=v*v;
System.out.print(min1);
System.out.print(" ");
System.out.print(max1);
System.out.println();
t--;
}
}
}
| Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 11 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output | |
PASSED | b7277f35edcd0f1cbc4b563517d9b5a4 | train_109.jsonl | 1636869900 | Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$$$$$ The solution $$$x = 0$$$, $$$y = 0$$$ is forbidden, so you should find any solution with $$$(x, y) \neq (0, 0)$$$. Please help Ivan to solve some equations of this form. | 256 megabytes | import java.util.*;
public class Main
{
static Scanner sc = new Scanner(System.in);
public static void main(String[] args)
{
try {
Slove();
}
catch(Exception e){
System.exit(0);
}
}
public static void Slove()
{
int t = sc.nextInt();
while(t -- > 0) {
long n = sc.nextLong();
long m = sc.nextLong();
System.out.println((-n * n)+" "+m*m);
}
}
} | Java | ["4\n1 1\n2 3\n3 5\n6 9"] | 1 second | ["-1 1\n-4 9\n-18 50\n-4 9"] | NoteIn the first test case: $$$\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}$$$.In the second test case: $$$\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}$$$.In the third test case: $$$\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}$$$.In the fourth test case: $$$\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}$$$. | Java 11 | standard input | [
"math"
] | 4dfa99acbe06b314f0f0b934237c66f3 | The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq 10^9$$$) — the parameters of the equation. | 800 | For each test case print two integers $$$x$$$, $$$y$$$ — a possible solution to the equation. It should be satisfied that $$$-10^{18} \leq x, y \leq 10^{18}$$$ and $$$(x, y) \neq (0, 0)$$$. We can show that an answer always exists. If there are multiple possible solutions you can print any. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.