Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- new Main().run();
- }
- void run() {
- Scanner in = new Scanner(System.in);
- int x = in.nextInt() % 8;
- final int d = in.nextInt();
- final long time = System.currentTimeMillis();
- int r = 0;
- for (int i = 0; i < 1234567890; i++) {
- x = (x + d) % 8;
- switch (x) {
- case 1:
- r += 2;
- break;
- case 3:
- r += 6;
- break;
- case 5:
- r += 9;
- case 7:
- r += 5;
- break;
- default:
- r -= 3;
- }
- }
- System.out.println(r);
- System.out.println(System.currentTimeMillis() - time);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement