Mathematically beautiful numbers
Max. score: 100
While playing a mental math game, you realize that the number k is mathematically beautiful.
You then realize that the number x can be mathematically beautiful if it is represented as a sum of a sequence where each element is a power of k and all the numbers in the sequence are different.
Task
Your task is to determine whether the number is mathematically beautiful.
Input format
- The first line contains T denoting the number of test cases.
- The next T lines contain and denoting the numbers.
Output Format
For each test case, output "YES" if is "mathematically beautiful" and "NO" otherwise.
Constraints
Explanation
Time Limit:2.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB
Marking Scheme:Score is assigned if any testcase passes.
Allowed Languages:Bash, C, C++, C++14, C++17, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, Java 14, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, Python 3.8, Racket, Ruby, Rust, Scala, Swift-4.1, Swift, TypeScript, Visual Basic
Comments
Post a Comment