Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _5_BitsUp {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner scan = new Scanner(System.in);
- int count = scan.nextInt();
- int step = scan.nextInt();
- int positionInSeq = 0;
- for (int i = 0; i < count; i++) {
- int number = scan.nextInt();
- for (int bit = 7; bit >= 0; bit--) {
- if ((step == 1 && positionInSeq > 0) || positionInSeq % step == 1) {
- int bitMask = 1 << bit;
- number |= bitMask;
- }
- positionInSeq++;
- }
- System.out.println(number);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement