Alien Generator Solution Google Kickstart 2021

Alien Generator Solution Google Kickstart 2021 Problem Astronauts have landed on a new planet, Kickstartos. They have discovered a machine on the planet: a generator that creates gold bars. The generator works as follows. On the first day, an astronaut inputs a positive integer KK into the generator. The generator will produce KK gold bars that day. The next … Read more

Smaller Strings Solution Google Kickstart 2021

Smaller Strings Solution Google Kickstart 2021 Problem You are given an integer KK and a string SS of length NN, consisting of lowercase letters from the first KK letters of the English alphabet. Find the number of palindrome strings of length NN which are lexicographically smaller than SS and consist of lowercase letters from the first KK letters of the English alphabet. A string composed of ordered letters a1,a2,…,ana1,a2,…,an is … Read more

Double or NOTing Solution Code Jam 2021

Double or NOTing Solution Code Jam 2021 Problem You are given a starting non-negative integer SS and an ending non-negative integer EE. Both SS and EE are given by their binary representation (that is, they are given written in base 22). Your goal is to transform SS into EE. The following two operations are available to you: Double your current value. Take the bitwise NOT of … Read more

Roaring Years Solution Code Jam 2021

Problem Something is happening in 20212021 that has not happened in over a century. 20212021, like 19201920 before it, is a roaring year. A year represented by a positive integer yy is roaring if the decimal writing (without leading zeroes) of yy is the concatenation of the decimal writing (without leading zeroes) of two or more distinct consecutive positive integers, in increasing order. In … Read more

Closest Pick Solution Code Jam 2021

Problem You are entering a raffle for a lifetime supply of pancakes. NN tickets have already been sold. Each ticket contains a single integer between 11 and KK, inclusive. Different tickets are allowed to contain the same integer. You know exactly which numbers are on all of the tickets already sold and would like to maximize your odds of winning … Read more

[Solution] GCD Sum Codeforces Round #711

The gcdSumgcdSum of a positive integer is the gcdgcd of that integer with its sum of digits. Formally, gcdSum(x)=gcd(x, sum of digits of x)gcdSum(x)=gcd(x, sum of digits of x) for a positive integer xx. gcd(a,b)gcd(a,b) denotes the greatest common divisor of aa and bb — the largest integer dd such that both integers aa and bb are divisible by dd. For example: gcdSum(762)=gcd(762,7+6+2)=gcd(762,15)=3gcdSum(762)=gcd(762,7+6+2)=gcd(762,15)=3. Given an integer nn, find the smallest integer x≥nx≥n such that gcdSum(x)>1gcdSum(x)>1.Input The first line of input contains one integer tt (1≤t≤104)(1≤t≤104) — the … Read more