import java.io.*;
import java.util.IllegalFormatException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
public class Main{
public static void main(String[] args) throws FileNotFoundException {
TextIO.readStream(System.in);
while(true){
int num=TextIO.getInt();
if(num==0)
break;
String temp=Integer.toBinaryString(num);
int length=Integer.bitCount(num);
System.out.println("The parity of "+temp+" is "+length+" (mod 2).");
}
}
}
import java.util.IllegalFormatException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
public class Main{
public static void main(String[] args) throws FileNotFoundException {
TextIO.readStream(System.in);
while(true){
int num=TextIO.getInt();
if(num==0)
break;
String temp=Integer.toBinaryString(num);
int length=Integer.bitCount(num);
System.out.println("The parity of "+temp+" is "+length+" (mod 2).");
}
}
}
No comments:
Post a Comment