CSES - Aalto Competitive Programming 2024 - wk5 - Mon - Results
Submission details
Task:Sum of ones
Sender:aalto2024e_007
Submission time:2024-09-30 16:59:09 +0300
Language:Java
Status:READY
Result:
Test results
testverdicttime
#10.13 sdetails
#20.13 sdetails
#30.13 sdetails
#40.13 sdetails
#50.13 sdetails
#60.13 sdetails
#70.14 sdetails
#80.13 sdetails
#90.13 sdetails
#100.13 sdetails
#110.14 sdetails
#120.13 sdetails
#130.13 sdetails
#140.13 sdetails
#150.14 sdetails
#160.13 sdetails
#170.13 sdetails
#180.13 sdetails
#190.13 sdetails
#200.13 sdetails
#210.13 sdetails

Code

//package week5.monday;

import java.util.Scanner;

public class BitCoun {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int number = 0;
		try {
			number = Integer.parseInt(sc.nextLine());
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			System.err.println("Your number sh not e <10000000000");
			main(args);
		}
		
		int oneBit = 0;
		 
		for(int i =1; i<=number; i++) {
			String binary = Integer.toBinaryString(i);
			for(int bitChar =0 ; bitChar < binary.length(); bitChar++) {
				if(binary.charAt(bitChar) == '1') oneBit++;
			}
		}
		System.out.println("hello");
		System.out.println(oneBit);
		sc.close();
	}
}

Test details

Test 1

Verdict:

input
1

correct output
1

user output
hello
1

Test 2

Verdict:

input
2

correct output
2

user output
hello
2

Test 3

Verdict:

input
3

correct output
4

user output
hello
4

Test 4

Verdict:

input
4

correct output
5

user output
hello
5

Test 5

Verdict:

input
5

correct output
7

user output
hello
7

Test 6

Verdict:

input
6

correct output
9

user output
hello
9

Test 7

Verdict:

input
7

correct output
12

user output
hello
12

Test 8

Verdict:

input
8

correct output
13

user output
hello
13

Test 9

Verdict:

input
9

correct output
15

user output
hello
15

Test 10

Verdict:

input
10

correct output
17

user output
hello
17

Test 11

Verdict:

input
303021765044187

correct output
7250167017244884

user output
(empty)

Error:
Your number sh not e <10000000000
Exception in thread "main" java.util.NoSuchElementExcept...

Test 12

Verdict:

input
390977392667778

correct output
9400236781929604

user output
(empty)

Error:
Your number sh not e <10000000000
Exception in thread "main" java.util.NoSuchElementExcept...

Test 13

Verdict:

input
670904313808571

correct output
16399391652009372

user output
(empty)

Error:
Your number sh not e <10000000000
Exception in thread "main" java.util.NoSuchElementExcept...

Test 14

Verdict:

input
704275111916256

correct output
17252936460583174

user output
(empty)

Error:
Your number sh not e <10000000000
Exception in thread "main" java.util.NoSuchElementExcept...

Test 15

Verdict:

input
799807335176164

correct output
19646099779305746

user output
(empty)

Error:
Your number sh not e <10000000000
Exception in thread "main" java.util.NoSuchElementExcept...

Test 16

Verdict:

input
852012055430877

correct output
21005540865890493

user output
(empty)

Error:
Your number sh not e <10000000000
Exception in thread "main" java.util.NoSuchElementExcept...

Test 17

Verdict:

input
901305628563213

correct output
22232965316761961

user output
(empty)

Error:
Your number sh not e <10000000000
Exception in thread "main" java.util.NoSuchElementExcept...

Test 18

Verdict:

input
917427461591619

correct output
22650112032503064

user output
(empty)

Error:
Your number sh not e <10000000000
Exception in thread "main" java.util.NoSuchElementExcept...

Test 19

Verdict:

input
981787468874797

correct output
24322274256024775

user output
(empty)

Error:
Your number sh not e <10000000000
Exception in thread "main" java.util.NoSuchElementExcept...

Test 20

Verdict:

input
1000000000000000

correct output
24784747400675348

user output
(empty)

Error:
Your number sh not e <10000000000
Exception in thread "main" java.util.NoSuchElementExcept...

Test 21

Verdict:

input
989898989898989

correct output
24531282955144033

user output
(empty)

Error:
Your number sh not e <10000000000
Exception in thread "main" java.util.NoSuchElementExcept...