Advertisement
Guest User

Untitled

a guest
Dec 6th, 2011
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String[] args) {
  7.         new Main().run();
  8.     }
  9.  
  10.     void run() {
  11.         Scanner in = new Scanner(System.in);
  12.         int x = in.nextInt() % 8;
  13.         final int d = in.nextInt();
  14.         final long time = System.currentTimeMillis();
  15.         int r = 0;
  16.         for (int i = 0; i < 1234567890; i++) {
  17.             x  = (x + d) % 8;
  18.             switch (x) {
  19.                 case 1:
  20.                     r += 2;
  21.                     break;
  22.                 case 3:
  23.                     r += 6;
  24.                     break;
  25.                 case 5:
  26.                     r += 9;
  27.                 case 7:
  28.                     r += 5;
  29.                     break;
  30.                 default:
  31.                     r -= 3;
  32.             }
  33.         }
  34.         System.out.println(r);
  35.         System.out.println(System.currentTimeMillis() - time);
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement