Problems

Pick a problem and write your solution in the built-in editor. The judge runs it against real test cases while you watch, and the wider archive is open to read whenever you like.

Total results1,202 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Least Common Multiple and Greatest Common DivisorFor multiple integer pairs, compute and print each pair's least common multiple and greatest common divisor.Easy1MathNumber theoryNo attempts yet1s128 MBJudgeable
Jerry and TomSubtract the fraction A/B from 1 and print the remaining cheese as P/Q in lowest terms.Easy1MathNumber theory+1No attempts yet1s128 MBJudgeable
Fraction SumAdd two given fractions and output the sum reduced to lowest terms using GCD.Easy2MathNumber theory+1No attempts yet2s128 MBJudgeable
Least Common MultipleFor each of up to 1000 pairs of numbers, compute and print the least common multiple.Easy2MathNumber theoryNo attempts yet1s128 MBJudgeable
Restoring NumbersFor each given integer up to 100,000, output its prime factorization as prime-exponent pairs in increasing order.Easy2MathNumber theory+1No attempts yet2s128 MBJudgeable
Greatest Common Divisor and Least Common MultipleGiven two natural numbers up to 10000, output their greatest common divisor and least common multiple.Easy2MathNumber theoryNo attempts yet1s128 MBJudgeable
Next NumberGiven three distinct integers from an arithmetic or geometric progression, decide which type it is and print the label with the next term.Easy2MathImplementation+2No attempts yet1s128 MBJudgeable
RecipesMultiply each recipe amount by a constant and print the result as a reduced integer or mixed fraction.Easy2ImplementationMath+1No attempts yet1s128 MBJudgeable
Greatest Common DivisorRead n pairs of positive integers and print the greatest common divisor of each pair on its own line.Easy2MathNumber theory+1No attempts yet1s128 MBJudgeable
Least Common MultipleFor each of n test cases, read two natural numbers a and b and print their least common multiple.Easy2MathNumber theory+1No attempts yet1s128 MBJudgeable
PerfectionFor each number below 60000, sum its proper divisors and classify it as perfect, deficient, or abundant.Easy2MathNumber theory+1No attempts yet1s128 MBJudgeable
Terms of OfficePrint every year from X to Y in which all four offices change, which happens on multiples of lcm(4,2,3,5) = 60, formatted as a fixed sentence.Easy2MathImplementation+2No attempts yet1s128 MBJudgeable
Fraction ActionReduce a numerator and denominator to simplest form, then print it as a whole number, a proper fraction, or a mixed number.Easy2MathNumber theory+1No attempts yet1s128 MBJudgeable
Mod InverseGiven x and m, find n with 0 < n < m such that x*n mod m equals 1, or report that none exists.Easy2Number theoryBrute forceNo attempts yet1s128 MBJudgeable
DivisibilityGiven a base-62 string, decide whether the number it represents is divisible by 61.Easy2MathNumber theory+1No attempts yet1s128 MBJudgeable
TeleprimeGiven a six-digit number and a digit to prepend, print Yes if both the original and the resulting seven-digit number are prime.Easy2Number theoryMath+2No attempts yet1s128 MBJudgeable
Non-DivisorsGiven n, print the smallest and the largest integers from 1 to n that do not divide n.Easy2Number theoryMathNo attempts yet1s128 MBJudgeable
Perfect Number CheckDecide whether each given integer equals the sum of its proper divisors and print the equation or a negative verdict.Easy2Number theoryImplementationNo attempts yet2s128 MBJudgeable
EuclidRead two positive integers up to 32767 and print their greatest common divisor.Easy2Number theoryNo attempts yet2s512 MBJudgeable
Divisor CountFor each of up to 10 values of n below 10000, print n and its divisor count.Easy2Number theoryBrute forceNo attempts yet2s512 MBJudgeable
Least Common MultipleGiven two integers below 100,000,000, print their least common multiple, which can exceed the 32-bit range.Easy2MathNumber theory+1No attempts yet2s512 MBJudgeable
Math ContestGiven a huge decimal integer x, print YES if x is divisible by 9 and NO otherwise.Easy2Number theoryMath+1No attempts yet1s512 MBJudgeable
One Hundred to TenParse a ratio written as n:m, divide both numbers by their greatest common divisor, and print the reduced ratio in the same format.Easy2MathNumber theory+1No attempts yet2s512 MBJudgeable
Perfect, deficient, or abundantFor each of T numbers below 10000, sum its proper divisors and classify it as Perfect, Deficient, or Abundant.Easy2MathBrute force+1No attempts yet1s128 MBJudgeable
Bedtime Reading IGiven an integer I, compute the sum of all its divisors.Easy2MathNumber theory+1No attempts yet2s512 MBJudgeable
Sharing apples and bananasGiven a apples and b bananas, print every common divisor n of a and b with the per-friend apple and banana counts.Easy2MathNumber theory+1No attempts yet2s512 MBJudgeable
Congruent NumbersGiven the two legs of a right triangle as fractions p1/q1 and p2/q2, print 1 if the triangle's area is an integer, otherwise 0.Easy2MathNumber theory+1No attempts yet2s512 MBJudgeable
Sum Squared Digits FunctionFor each of P datasets, convert the given integer n to base b, square each digit, and report the total with the dataset number.Easy2MathImplementation+1No attempts yet2s512 MBJudgeable
Is N primeGiven an integer N, decide whether N is prime and print Yes or No. The trailing line of N integers is unused.Easy2MathNumber theory+1No attempts yet1s256 MBJudgeable
Overflow and ModuloMultiply N integers and print the product modulo M, reducing after each multiplication to avoid overflow.Easy2MathImplementation+2No attempts yet1s512 MBJudgeable
N! mod P (1)Given N and a prime P larger than N, compute N! modulo P.Easy2MathImplementation+2No attempts yet3s1024 MBJudgeable
Even or Odd?Given n, decide whether the sum of any n consecutive positive integers is always even, always odd, or depends on the starting point.Easy2MathImplementation+1No attempts yet1s512 MBJudgeable
ABCD CodeFor each four-digit code, check whether the square of its first two digits plus the square of its last two digits leaves remainder 1 modulo 7.Easy2MathImplementation+2No attempts yet2s512 MBJudgeable
DivisorsGiven all proper divisors of an unknown number N, compute N using the fact that the smallest and largest proper divisors multiply to N.Easy3MathNumber theory+1No attempts yet2s512 MBJudgeable
UnderprimeCount integers in a range whose total number of prime factors (with multiplicity) is itself a prime number.Easy3Number theoryMath+1No attempts yet2s128 MBJudgeable
Least Common Multiple of at Least Three NumbersGiven five distinct positive integers up to 100, find the smallest number divisible by at least three of them, essentially the minimum LCM over all triples.Easy3MathBrute force+2No attempts yet2s128 MBJudgeable
Lee-myeon and Im-hyeonClassify a number 1 to 2700 as Lee-myeon and/or Im-hyeon based on digit sum parity and prime factorization rules, then output one of four codes.Easy3Number theoryImplementation+1No attempts yet2s128 MBJudgeable
K-Sejun NumbersCount integers from 1 to N whose every prime factor is at most K, given N up to 100000 and K up to 100.Easy3MathNumber theory+1No attempts yet2s128 MBJudgeable
DietGiven G, find all natural numbers a such that a^2 minus some natural number's square equals G, printing them in increasing order or -1 if none exist.Easy3MathNumber theory+1No attempts yet2s128 MBJudgeable
Modular ExponentiationCompute A raised to the power B modulo C efficiently using fast modular exponentiation.Easy3MathNumber theory+1No attempts yet0.5s128 MBJudgeable
Number of Trailing Zeros in a FactorialCount the trailing zeros of N! for N up to 500 by counting factors of 5.Easy3MathNumber theory+1No attempts yet2s128 MBJudgeable
Encryption KeyDetermine for each large number S whether all its prime factors exceed one million, using trial division up to that bound.Easy3Number theoryMath+1No attempts yet2s128 MBJudgeable
Safe Password CheckGiven a number P equal to the product of two primes and a threshold K, decide if both primes are at least K, otherwise output the smaller prime.Easy3Number theoryMath+1No attempts yet2s256 MBJudgeable
Find Prime NumbersPrint all prime numbers between two given bounds M and N, one per line, using an efficient sieve up to 1,000,000.Easy3MathNumber theory+1No attempts yet2s256 MBJudgeable
Counting Consecutive SumsCount the number of ways to express a given natural number N as a sum of one or more consecutive natural numbers.Easy3MathNumber theoryNo attempts yet2s32 MBJudgeable
Diagonal Across TilesGiven a grid of x by y unit tiles, count how many tiles a diagonal from corner to corner passes through using the gcd formula.Easy3MathNumber theoryNo attempts yet1s128 MBJudgeable
Making Equal-Length SticksGiven piece lengths, find the smallest stick length such that all pieces can be regrouped into sticks of that equal length (the sum divided by a suitable divisor, bounded by the maximum piece).Easy3MathGreedy+1No attempts yet3s128 MBJudgeable
Greatest Common Divisor and Least Common MultipleGiven the gcd and lcm of two unknown natural numbers, find the pair with the smallest sum satisfying both conditions.Easy3Number theoryMath+1No attempts yet1s128 MBJudgeable
Prime NumbersGiven a range M to N up to 10,000, find all primes in it and print their sum plus the smallest one, or -1 if none exist.Easy3MathNumber theory+1No attempts yet1s128 MBJudgeable
Ruler and ProtractorGiven N base angles closable under addition/subtraction mod 360, determine for K query angles whether each is reachable, which reduces to checking divisibility by gcd of the base angles and 360.Easy3Number theoryMath+1No attempts yet1s128 MBJudgeable
Apple Distribution MethodsGiven R and G, list every common divisor N of both, printing N along with R/N and G/N as red and green apples per player.Easy3Number theoryMath+1No attempts yet1s128 MBJudgeable
Pascal Loop OutputGiven N up to 1e9, simulate finding the largest divisor of N smaller than N by scanning downward, and output how many steps that takes without brute force.Easy3MathNumber theory+1No attempts yet1s128 MBJudgeable
RingsGiven radii of N touching rings, compute how many rotations each ring after the first makes as a reduced fraction when the first ring completes one rotation.Easy3MathNumber theory+1No attempts yet1s128 MBJudgeable
Heart Number SystemConvert a decimal integer to balanced ternary notation using digits 1, 0, and - for -1, without leading zeros.Easy3MathNumber theory+1No attempts yet1s128 MBJudgeable
Cutting ChocolateGiven an N by M chocolate bar, find the minimum number of square pieces obtained by repeatedly cutting it fully along rows or columns.Easy3MathNumber theory+1No attempts yet1s128 MBJudgeable
Prime Gap SequenceGiven a number k, find the gap length between the two consecutive primes surrounding it if k is composite, otherwise output 0.Easy3MathNumber theory+1No attempts yet1s128 MBJudgeable
Remainder CalculationFor each test case, find the remainder when a base-B number D with up to ten million digits is divided by B-1.Easy3MathNumber theory+2No attempts yet1s256 MBJudgeable
Chain of FoolsGiven sprocket prongs, chain links, and start positions of a broken prong and bent link, find when they first meet at location 0, printing revolutions and fraction or Never.Easy3MathNumber theory+2No attempts yet1s128 MBJudgeable
BlocksGiven N unit cubes, find positive integers a, b, c with a*b*c = N that minimize the surface area 2(ab+bc+ca).Easy3Brute forceMath+2No attempts yet1s128 MBJudgeable
Geek Challenge [SKRZAT] (Base Minus Two)Convert numbers between decimal and base -2 (Weird Binary), echoing each query with its formatted result.Easy3MathImplementation+1No attempts yet1s128 MBJudgeable
Primorial Number SystemRepresent each positive integer in the mixed-radix primorial system where the i-th place value is the product of the first i primes.Easy3MathNumber theory+2No attempts yet1s128 MBJudgeable
Faulty OdometerRead odometer values that skip the digit 4 and print the true mileage by treating each reading as a base-9 number.Easy3MathImplementation+2No attempts yet1s128 MBJudgeable
Casting Out NinesFor each line like a+b=c. or a*b=c., compute digit sums modulo 9 and print PASS if the operation is congruent, otherwise NOT!.Easy3MathNumber theory+2No attempts yet1s128 MBJudgeable
Dirichlet's Theorem on Arithmetic ProgressionsFor each dataset, print the n-th prime in the arithmetic progression a, a+d, a+2d, ... , where a and d are coprime.Easy3Number theoryMath+1No attempts yet1s128 MBJudgeable
SequencesFor each query with a first term, non-zero common difference, and value, print the term index if the value is in the arithmetic sequence, otherwise X.Easy3MathImplementation+1No attempts yet1s128 MBJudgeable
Common DivisorsGiven 2 or 3 numbers up to 1e8, print every positive integer that divides all of them, in increasing order.Easy3MathNumber theory+2No attempts yet1s256 MBJudgeable
Divide and ConquerAmong integers from M to N, pick the one with the most divisors, breaking ties by the largest value, and report it with its divisor count.Easy3Number theoryBrute force+2No attempts yet1s128 MBJudgeable
Perfect SquaresGiven N, count ordered pairs (A, B) with 1 <= B <= A <= 500 and A^2 - B^2 = N.Easy3Brute forceMath+2No attempts yet1s128 MBJudgeable
Prime QualificationCount primes between A and B whose decimal representation contains the digit D.Easy3Number theoryMath+2No attempts yet2s128 MBJudgeable
The Drunken JailerA jailer toggles the doors of cells that are multiples of k in round k; count how many doors end up open after n rounds.Easy3MathNumber theory+2No attempts yet1s128 MBJudgeable
Digital RootGiven positive integers up to 1000 digits, each line until a terminating 0, print the digital root of each number.Easy3MathNumber theory+2No attempts yet1s128 MBJudgeable
Prime CutsFor each N and C, build the primes from 1 to N and print the middle C*2 or C*2-1 of them, or the whole list if that many do not exist.Easy3MathNumber theory+2No attempts yet1s128 MBJudgeable
Uniform GeneratorFor each pair STEP and MOD, decide whether seed(x+1) = (seed(x) + STEP) mod MOD cycles through all MOD values, which holds exactly when gcd(STEP, MOD) = 1.Easy3Number theoryMath+2No attempts yet1s128 MBJudgeable
Kilometers to MilesConvert each kilometer value to miles by writing it in Zeckendorf Fibonacci form, dropping the lowest bit, and re-evaluating.Easy3MathGreedy+2No attempts yet1s128 MBJudgeable
The Easiest Problem Is This OneFor each positive integer N up to 100000, find the smallest multiplier p greater than 10 such that N and N*p have the same decimal digit sum.Easy3Brute forceMath+2No attempts yet1s128 MBJudgeable
Goldbach's ConjectureFor each even n below 2^15, count the unordered pairs of primes that sum to n, stopping at a terminating 0.Easy3Number theoryMath+2No attempts yet1s128 MBJudgeable
Cool NumbersCount integers in [a, b] that are both a perfect square and a perfect cube, meaning perfect sixth powers.Easy3MathNumber theory+1No attempts yet1s128 MBJudgeable
RSA NumbersCount how many integers in an inclusive range below 1000 have exactly four divisors, then print the count in a fixed sentence.Easy3MathNumber theory+2No attempts yet1s128 MBJudgeable
Picture PerfectFor each C, find the factor pair (W, H) with W*H = C closest to a square, and report the smallest perimeter along with W and H.Easy3MathBrute force+2No attempts yet1s128 MBJudgeable
Deficient, Perfect, and AbundantFor each integer, sum its proper divisors and classify it as deficient, perfect, or abundant.Easy3MathNumber theory+1No attempts yet1s128 MBJudgeable
Big NumberFor each m up to 10^7, print the number of decimal digits in m factorial.Easy3MathNumber theory+1No attempts yet2s128 MBJudgeable
Can You Exponentiate?Given a and b up to 1e9, print the last decimal digit of a^b.Easy3MathNumber theory+1No attempts yet1s128 MBJudgeable
Smallest Perfect-Square MultipleRead n and print the smallest multiple of n that is a perfect square.Easy3Number theoryNo attempts yet1s128 MBJudgeable
Divisor Set InclusionDecide for each pair whether every divisor of a also divides b, which holds exactly when a divides b.Easy3Number theoryNo attempts yet1s128 MBJudgeable
The Cheerful MonkeyStarting from one closed cage in a circle of n, repeated jumps of length d open each landing cage until a repeat, and you count the opened cages.Easy3Number theoryMathNo attempts yet1s128 MBJudgeable
GymCount the integers from 1 to n that are multiples of a or of b.Easy3MathNumber theoryNo attempts yet1s128 MBJudgeable
Goldbach's ConjectureGiven an even number n, print the two primes that sum to n with the smallest gap between them.Easy3Number theoryTwo pointersNo attempts yet2s256 MBJudgeable
Primality TestDecide whether each of up to 10 numbers up to 100000000 is prime and print YES or NO.Easy3Number theoryMathNo attempts yet1s128 MBJudgeable
BiorhythmsGiven one peak day for each of the 23, 28, and 33 day cycles and a date d, find the days from d to the next day when all three peak together.Easy3Number theoryMathNo attempts yet1s128 MBJudgeable
Counting non-decreasing digit sequencesCount length-N non-decreasing sequences of digits 0 to 9, modulo 1000000007, for each test case.Easy3CombinatoricsNumber theoryNo attempts yet1s128 MBJudgeable
Largest Pairwise GCDFor each test case, print the largest GCD found among all pairs of the given integers.Easy3Number theoryBrute forceNo attempts yet1s128 MBJudgeable
GCD SumGiven several integers per test case, add the greatest common divisor of every unordered pair and print each sum.Easy3Number theoryBrute forceNo attempts yet1s128 MBJudgeable
SifarFor each N up to 1,000,000 given one per line until 0, print the count of trailing zeros of N! as Case #x: M.Easy3Number theoryMathNo attempts yet1s128 MBJudgeable
Product of two distinct primesFor each K, print the smallest number at or above K that equals the product of two different primes.Easy3Number theoryBrute forceNo attempts yet1s128 MBJudgeable
Six EquationsRecover six bounded primes from six pairwise products by taking gcds of the pairs that share a prime.Easy3Number theoryNo attempts yet1s128 MBJudgeable
Largest Pairwise GCDGiven up to 100 positive integers below one million, find the largest GCD over all pairs from distinct positions.Easy3Brute forceNumber theoryNo attempts yet1s128 MBJudgeable
Common FractionReduce each of n fractions to lowest terms by dividing out the greatest common divisor.Easy3Number theoryNo attempts yet1s128 MBJudgeable
The nth prime numberGiven n up to 10000, print the nth prime number.Easy3Number theoryMathNo attempts yet2s512 MBJudgeable
Federation FavoritesRead integers until -1 and print each perfect number with its divisors or state that it is not perfect.Easy3Number theoryImplementationNo attempts yet1s256 MBJudgeable
RibbonAfter dropping the dirty inch at each end of every roll, find the longest common piece length that uses up every roll and count the total pieces.Easy3Number theoryNo attempts yet2s256 MBJudgeable