You are viewing a single comment's thread. Return to all comments →
Some testcases are failing, please help
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); int globalNum = num; if (num==1) { System.out.println("Richard");//always Richard } while(num!=1){ if(isPowerOf2(num)){//richard int divident = num/2; num = divident; if(num==1){ System.out.println("Richard"); } }else { while(!isPowerOf2(num)){//louise if(num>0){ num--; } } int temp = globalNum-num; globalNum=temp; num=temp; if(num==1){ System.out.println("louise"); } } } } private static boolean isPowerOf2( int n) { if (n <= 0) { return false; } return Integer.bitCount(n) == 1; } }
Seems like cookies are disabled on this browser, please enable them to open this website
Counter game
You are viewing a single comment's thread. Return to all comments →
Some testcases are failing, please help
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {