Submit solution
Points:
5
Time limit:
2.0s
Memory limit:
64M
Author:
Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
Your computer science teacher has kindly requested that you write a program to convert a number, inputted in decimal, to binary to help in teaching students about binary. Also to aid in human processing of numbers, you should group every four bits and separate the groups by space.
Input Specification
The first line will be integer (
), the number of numbers to convert to binary. The next
lines will be
such that (
).
Output Specification
For every integer , output the binary representation, grouped into four bit groups, separated by spaces. If necessary, you must pad the first group to have exactly four bits.
Sample Input
3
1
10
255
Sample Output
0001
1010
1111 1111
Comments
I tested my code using eclipse while comparing it to a binary converter, and my answers appear to be correct however I'm getting WA for my tests. I thought it may be an issue with my formatting/spacing, so I debugged that but it still seems to be incorrect. Is there a different problem with my formatting?
I think the Haskell compiler is a bit outdated, I can't use
Data.List.Split
libraries :( .Could someone tell me why I have an IR on all of my answers? I checked my code, and there shouldn't be an error with the strings.
My program seems to work for the test cases, as well as other tests with numbers. I'm not sure why I'm getting WA, is there something wrong with my output formatting?
Why am I not passing test case #1?
Edit: nvm, how do i delete a comment
Is it possible to see the input for test case 1, 7th conversion (8th line of input)? My students and I are getting WA for this case, but are ACing all the other test cases. I'm sure it's something minor, but we're a bit stumped right now.
You aren't handling the case where
.
Thanks!
im new too python may anyone please tell me how to figure out these problems i am confused on what he is sasking me to do. What does this mean? > N N ( 1 ≤ N ≤ 20 1 \le N \le 20 ). and this? > The next N N lines will be i i such that ( i ∈ Z , 0 ≤ i ≤ 10 9 i \in \mathbb{Z}, 0 \le i \le 10^9 ).I would be very grateful if you could help me.
This comment is hidden due to too much negative feedback. Click here to view it.
Java has a method you can call against the Integer class: Integer.toBinaryString(number);
Other Hint: Python3 has a function called 'bin'
I had been making a "gen_binary" function and all this time there was one built-in! I still need to refine the "bin"'s output though, so the "gen_binary" function won't be useless.
Note the output specification: (1) 16 --> 10000,output should be:
0001 0000,output should not be:1000 0 (2) 0 --> 0000,1 --> 0001, 7 --> 0111
what is the output if the input is 0
I tested my solution using eclipse and all the test cases are correct, why am I getting WA in my submissions?
UPDATE: Nvm, I was making a stupid mistake
It seems that im getting the right answers, but im still getting wa. Is there anything wrong with how i'm using sys.stdout.write?
There is more than one input.