src stringlengths 95 64.6k | complexity stringclasses 7
values | problem stringlengths 6 50 | from stringclasses 1
value |
|---|---|---|---|
import java.util.*;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n % 2 == 0) {
System.out.println(4 + " " + (n - 4));
} else {
System.out.println(9 + " " + (n - 9));
}
}
} | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.Scanner;
public class code0 {
public static void main(String[] args){
Scanner scr= new Scanner(System.in);
int c=0,e=0,d=0;
int a=scr.nextInt();
d=a/2;
if(a>=11 && a%2==1){
c=9;
e=a-9;
}
else{
c=a-4;e=4;
}
System.out.print(c+" "+e);
}
}
| constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.Scanner;
/**
*
* @author RezaM
*/
public class A {
public static void main(String[] args) {
Scanner... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.*;
public class A {
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
int n = s.nextInt();
s.close();
if (n % 2 == 0)
System.out.print("4 " + (n-4));
else
System.out.print("9 " + (n-9));
}
}
| constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.*;
import java.util.*;
public class a
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int N=sc.nextInt();
solve(N);
}
static void solve(int a)
{
if((a-8)%3==0)
{
System.out.println(8+" "+(a-8));
return ;
}
if((a-4)%3==0)
{
Syst... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ProblemA {
public static void main(String [] args) throws NumberFormatException, IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine()... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.Scanner;
/**
* Created by misanand on 9/20/14.
*/
public class Recovery {
public static void main(String [] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
if( N%2 == 0) {
System.out.println( (4)+" "+(N-4));
}
else System... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.Scanner;
public class main1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a = n / 2;
int b = n - a;
if (n % 2 == 0) {
if (a % 2 == 1) {
a++;
b--;
}
System.out.println(a + " " + b);
} else {
if (a... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;
/**
* Built using CHelper... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int one, two;
if(n%2 == 0)
{
one = two = n/2;
if(one%2 != 0 && two%2 != 0)
... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
if (n % 2 == 0) {
System.out.println((n - 4) + " " + (n - (n - 4)));
} else {
System.out.println((n - 9) + " " +... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Anirudh Rayabharam (anirudhrb@yandex.com)
*/
public class Mai... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.IOException;
import java.util.Scanner;
/**
* TODO: describe
*
* @author keks
*/
public class A {
public static void main(String[] args) throws IOException {
final Scanner sc = new Scanner(System.in);
final int n = sc.nextInt();
if (n % 2 == 0) {
System.out.pri... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.*;
import java.io.*;
public class Cf270a {
public static void main(String[] args) throws IOException {
InputStreamReader fin = new InputStreamReader(System.in);
Scanner scr = new Scanner(fin);
int n = scr.nextInt();
int x = 0;
int y = 0;
if (n%2 == 0)... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class TA {
public void solve(long n) {
long a = 0, b = 0;
if (n % 2 == 0) {
if (n % 4 == 0) {
a = n / 2;
... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.Scanner;
public class J472A {
private static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
int a = scan.nextInt();
if(a % 2 == 0) {
System.out.println(4 + " " + (a - 4));//ż���4
} else {
System.out.println(9 + " " + (a - 9));//������
}
}
}
| constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a,b;
if (n%2==0) {
a = 4;
}else{
a = 9;
}
b = n - a;
System.out.println(a + " " + b);
}
}
| constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int a = n/2;
int b = (n/2) + (n%2);
if ((a%2!=0 && a%3!=0) || (b%2!=0 && b%3!=0)) {
a--;
... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.Scanner;
public class composite {
public static void main(String[] args) {
int b;
Scanner s3=new Scanner(System.in);
b=s3.nextInt();
if(b%2==0)
{
b=b-4;
System.out.println(4+" "+b);
}
else
... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
BufferedReader in;
StringTokenizer st;
PrintWriter out;
String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(in.readLine());
return st.nextToken();
}
int nextInt() throws Exception {
return Integer... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
// main
public static void main(String [] args) throws IOException {
// makes the reader and writer
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.Scanner;
public class A470 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int start=4;
while(true){
if((start%2==0||start%3==0)&&((n-start)%2==0||(n-start)%3==0))
{
System.out.println(start+" "+(... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) throws IOException{
BufferedReader br = new Buffere... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author bdepwgjqet
*/
public class ... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
public class p472a {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n % 2 == 0) {
System.out.println("8 " + (n - 8));
} else {
System.out.printl... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.*;
public class A
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
if(n % 2 == 1)
{
System.out.println(9 + " " + (n - 9));
}
else
{
System.out.println(4 + " " + (n - 4));
}
}
}
| constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
public class Problem1 {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
B... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Test {
public static void main(String[] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
//StringTokenizer st=new StringToken... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
public static boolean isPrime(long num){
int divisor = 2;
boolean bandera = true;
while(bandera && divisor<num) //ponemos el while con su condicion en este caso si bandera
... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
int n,a,b;
Scanner obj=new S... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.*;
import static java.lang.Math.*;
import java.io.*;
public class SolutionB {
public static void main(String args[])throws IOException{
Scanner sc = new Scanner(System.in);
int a[] = new int[1501];
for(int i = 0; i < 3; i++){
a[sc.ne... | constant | 911_C. Three Garlands | CODEFORCES |
import java.io.*;
import java.math.*;
import java.util.*;
// author @mdazmat9
public class codeforces{
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int test = 1;
for (int ind = 0; i... | constant | 911_C. Three Garlands | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test3 {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int x=Integer.parseInt(br.readLine());
int ... | constant | 913_A. Modular Exponentiation | CODEFORCES |
/**
* Author: Ridam Nagar
* Date: 27 February 2019
* Time: 01:17:36
**/
/*
package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{ ... | constant | 913_A. Modular Exponentiation | CODEFORCES |
import java.math.BigInteger;
import java.util.Scanner;
public class RENAMETHISBITCH {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
int n = sc.nextInt();
BigInteger m = sc.nextBigInteger();
System.out.println(m.mod(BigInteger.valueOf(2).pow(n)));
}
c... | constant | 913_A. Modular Exponentiation | CODEFORCES |
import java.util.*;
import java.io.*;
public class aaaaaaaaaaaaaaaa {
public void run() throws Exception {
Scanner file = new Scanner(System.in);
int a = file.nextInt(), b= file.nextInt(), c = file.nextInt(), n = file.nextInt();
a -= c;
b -= c;
if (a < 0 || b < 0) System.out.println(-1);
else {
int x =... | constant | 991_A. If at first you don't succeed... | CODEFORCES |
import java.util.*;
public class helloWorld
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
int n = in.nextInt();
int ans = n - (a + b - c);
if(ans < 1 || a >= n || b >= n || c > a || c > b)
ans = ... | constant | 991_A. If at first you don't succeed... | CODEFORCES |
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.StringTokenizer;
... | constant | 1080_C. Masha and two friends | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
FastScanner in;
PrintWriter out;
void solve() {
long a = in.nextLong(), b = in.nextLong();
long ans = 0;
while (true) {
long div = a / b;
ans += div;
a -= div * b;
if (a == 0) {
break;
}
long tmp = a;
a = b;
b = ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.Scanner;
public class A {
public static final boolean DEBUG = false;
Scanner sc;
public void debug(Object o) {
if (DEBUG) {
int ln = Thread.currentThread().getStackTrace()[2].getLineNumber();
String fn = Thread.currentThread().getStackTrace()[2].getFileName();
System.out.println("(" + ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args){
FastScanner sc = new FastScanner();
long a = sc.nextLong();
long b = sc.nextLong();
long result = 0L;
while(a != 0 && b != 0) {
if(a > b) {
result += a/b;
a = a % b;
} else ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
long solve(long a, long b) {
return b == 0 ? 0 : a / b + solve(b, a % b);
}
public void run() {
try {
long a = reader.nextLong();
long b = reader.nextLong();
writer.println(sol... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
long solve(long a, long b) {
if (a == 0) {
return 0;
}
long answer = a / b;
a %= b;
if (a != 0) {
answer += 1 + solve(b - a, a);
}
return answer;
}
... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author George Marcus
*/
public class Main {
public static void main(String[] args) {
Inpu... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class A
{
public static void main(String [] args) throws IOException
{
Scanner in = new Scanner(System.in);
System.... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.StringTokenizer;
public class Contest200C {
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//BufferedReader in = new BufferedReader(new FileReader("200C.in"));
StringTokenizer st = new String... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
long a=s.nextLong(), b=s.nextLong();
long c=0;
while(true) {
if(a==b ){
System.out.println(c+a);
return ;
... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args) throws Throwable {
new A().go();
}
void p(String s) {
System.out.println(s);
}
void go() throws Throwable {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String[]... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.*;
public class A {
private static Scanner in;
public void run() {
long a = in.nextLong();
long b = in.nextLong();
long ans = 0;
while (a > 0 && b > 0) {
if (a >= b) {
ans += a / b;
a %= b;
continue;
}
ans += b / a;
b %= a;
}
System.out.println(ans);
}
public ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.*;
public class NewEmpty
{
public static void main(String[] args)
{
Scanner blabla=new Scanner(System.in);
long a,b,c=0,d;
a=blabla.nextLong();
b=blabla.nextLong();
while (b!=0){
c+=(a/b);
a=a%b;
d=a;
a=b;
... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
boolean eof;
public static void main(String[] args) throws IOException {
new Main().run();
}
public String nextToken() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (Exception e) {
e... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class cf343a {
static FastIO in = new FastIO(), out = in;
public static void main(String[] args) {
out.println(go(in.nextLong(),in.nextLong()));
out.close();
}
static long go(long a, long b) {
return b==0?0:(go(b,a%b) + a/b);
}
static class FastIO ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.Scanner;
public class RationalResistance {
static long n = 0;
static void R(long a, long b) {
n += a / b;
a %= b;
if (a == 0) {
return;
}
R(b, a);
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
long a = cin.nextLong();
long b = cin.nextLong();... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class taskA {
void solve() throws IOException {
long a = nextLong();
long b = nextLong();
long ans = 0;
while (a != 0 && b != 0) {
if (a > b) {
ans += a / b;
a %= b;
} else {
long c = b % a;
ans += b / a;
b = a;
a = c;
}
}
ou... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class p343a
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println();
long a = sc.nextLong();
long b = sc.nextLong();
if(a==b) System.out.println("1");
else if(b==1) System.o... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
static void solve() throws IOException {
long a = nextLong(), b = nextLong();
long answer = get(a, b);
out.println(answer);
}
private static long get(long p, long q) {
if (p == 0) {
return 0;
}
if (q == 1) {
return p;
}
if (p == 1) {
... | constant | 343_A. Rational Resistance | CODEFORCES |
//package CF;
// Div One
import java.util.*;
public class CFA_200 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long x = sc.nextLong();
long y = sc.nextLong();
System.out.println(Wilf_tree(x, y));
sc.close();
}
static long Wilf_tree(long a,long b)
{
if(a==0|... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Soal3 {
public static void main(String[] args) throws IOException{
BufferedReader baca = new BufferedReader(new InputStreamReader(System.in));
String[] masukan = ba... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.*;
import java.lang.*;
import java.io.*;
public class Ideone {
static long ans=0;
public static void Stepgcd(long a,long b) {
if (b!=0) {ans+=(a/b);Stepgcd(b,a%b);}
}
public static void main (String[] args) throws java.lang.Exception {
Scanner in=new Scanner(System.in);
long a=in.nextLon... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
long gcd(long a, long b) {
if (b == 0) {
return a;
} else {
return gcd(b, a % b);
}
}
long solve(long a,long b) {
if (a == 0 || b ==0) {
return 0;
}
long t = gcd(a,b);
a /= t;
b /= t;
if (a>b) {
return solve(a%b,b)+a/b;
} else ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
public class Task343A {
public static void main(String... args) throws NumberFormatException,
IOException {
... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class A {
BufferedReader reader;
StringTokenizer tokenizer;
PrintWriter out;
public void solve() throws IOException {
long A = nextLong();
long B ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(S... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import org.omg.CORBA.UNKNOWN;
public class HelloWorld {
InputReader input;
PrintWriter output;
BufferedReader inp;
void run... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author dudkamaster
*/
public class... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main implements Runnable {
public void _main() throws IOException {
long a = nextLong();
long b = nextLong();
long res = 0;
while (b > 0) {
res += a / b;
long t = a % b;
a = b;
b = t;
}
out.println(res);
}
private BufferedReader in;
priv... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author sheep
*/
public class Main ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;
/**
*... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.Scanner;
public class C {
static long n = 0;
static void R (long a,long b){
n += a/b;
a = a%b;
if(a==0) return;
R(b,a);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long a = sc.nextLong();
long b = sc.nextLong();
R(a,b);
System.out.printl... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class CF {
long getAns(long a, long b) {
if (a == b)
return 1;
if (a < b) {
return getAns(b, a);
}
// a > b
long cnt = (a - 1) / b;
return cnt + getAns(b, a - b * cnt);
}
void solve() {
long a = in.nextLong();
long b = in.nextLong();
out.println... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
public class ProblemA {
static final int INF = 100000000;
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new Inpu... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class A {
static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st = new StringTokenizer("");
static String readString() throws Exception {
while(!st.has... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.Scanner;
public class C344C {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long a = sc.nextLong();
long b = sc.nextLong();
long count = a / b, c;
a = a % b;
while(true){
if (a <= 1 || b <= 1) break;
c = b - a;
b = a;
a = c;
count++;
if ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class RationalResistance {
public static void main(String args[]) throws IOException{
BufferedReader f= new BufferedReader(new InputStreamReader(System.... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
public static long func(long a, long b) {
if (a < b)
return func(b, a);
if (b < 2)
return a;
long q = a / b;
long r = a - q * b;
return q + func(b, r);
}
public static v... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.math.*;
import java.util.*;
import static java.lang.Math.*;
public class Main implements Runnable {
public void solve() throws Throwable {
long a = sc.nextLong();
long b = sc.nextLong();
long ans = 0;
while (a > 0 && b > 0) {
... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
public static void main(String args[]) throws IOException {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String line = stdin.readLine();
String[] prms = line.split(" ");
long a = Long.parseLong(prms[0]);
... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.awt.Point;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class A {
static StringTokenizer s... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.*;
public class c {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
long a = input.nextLong(), b = input.nextLong();
System.out.println(gcd(a, b));
}
static long gcd(long a, long b)
{
if(b==1) return a;
if(a==1) return b;
if(a>b) return a/b + gcd... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) throws Exception {
new A().doit();
}
private void doit() throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
S... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.*;
public class A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long A = in.nextLong();
long B = in.nextLong();
System.out.println(f(A,B));
}
static long f(long A, long B) {
if(A==0) return 0;
if(A < B) retur... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.*;
public class p343A
{
static long n = 0;
static void resistance(long a, long b)
{
n += a/b;
a %= b;
if(a!=0) resistance(b, a);
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long a = in.nextLong();
... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class RationalResistance {
public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(f.readLine());
long a = Long.parseLong(st.nex... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
import static java.lang.Math.*;
public class Solution implements Runnable {
public long gcd(long a, long b) {
long tmp;
while (b > 0) {
a %= b;
tmp = a;
a = b;
b = tmp;
}
return a;
}
public void solve() throws Exc... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.Scanner;
import java.io.StreamTokenizer;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution i... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class cf {
static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
try {
br = new BufferedReader(new InputStreamReader(System.in));
st = new StringTokenizer(br.readLine()... | constant | 964_A. Splits | CODEFORCES |
import java.io.PrintWriter;
import java.util.*;
import java.util.Arrays ;
import java .lang.String.* ;
import java .lang.StringBuilder ;
public class Test{
static int pos = 0 ;
static int arr[] ;
static LinkedList l1 = new LinkedList() ;
static void find(int p ,char[]x,int put[],String s){
int c... | constant | 964_A. Splits | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
public class CodeForces
{
public static void main(String[] args)
{
Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
System.out.println(input.nextInt() / 2 + 1);
}
} | constant | 964_A. Splits | CODEFORCES |
import java.util.*;
import java.io.*;
public class programA {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
if(n%2 == 0)System.out.println(n/2 +1);
else System.out.println((int)Mat... | constant | 964_A. Splits | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/**
*
* @author Antonio "Teo" Alurralde
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReade... | constant | 1033_A. King Escape | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
public class KingEscape {
public static void main(String[] args) {
Reader read = new Reader();
int n = read.nextInt();
int a1 = read.nextInt();
... | constant | 1033_A. King Escape | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Solve4 {
public static void main(String[] args) throws IOException {
FastReader sc = new FastReader();
int x= sc.nextInt();
int y= sc.nextInt();
int z... | constant | 1054_A. Elevator or Stairs? | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main (String[] args) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
String parameterStringList[] = reader.readLine(... | constant | 1054_A. Elevator or Stairs? | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class ElevatorOrStairs {
private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
private static final OutputStreamWriter writer = new OutputStreamWriter(System.out);
... | constant | 1054_A. Elevator or Stairs? | CODEFORCES |
import java.util.Scanner;
public class Sasha1113A {
static int solution(int n, int v){
int count;
if(v>=n)
return n-1;
else{
count = (v-1) + ((n-v)*(n-v+1))/2;
}
return count;
}
public static v... | constant | 1113_A. Sasha and His Trip | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import ja... | constant | 915_B. Browser | CODEFORCES |
import java.util.Scanner;
public class LuckyDivision {
public static void main (String[] args) {
Scanner read = new Scanner(System.in);
int n = read.nextInt();
if (n % 4 == 0 ||
n % 7 == 0 ||
n % 47 == 0 ||
n % 74 == 0 ||
n % 447 == 0 ||
n % 474 == 0 ||
n % 477 == 0 ||
n % 744 == 0 ||
... | constant | 122_A. Lucky Division | CODEFORCES |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.