This repository was archived by the owner on Feb 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlosrtcow.java
More file actions
63 lines (52 loc) · 1.53 KB
/
losrtcow.java
File metadata and controls
63 lines (52 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.io.*;
import java.util.*;
public class losrtcow {
public static String repeat(int count, String with) {
return new String(new char[count]).replace("\0", with);
}
public static String changen(int position, char ch, String str){
char[] charArray = str.toCharArray();
charArray[position] = ch;
return new String(charArray);
}
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader f=new BufferedReader(new FileReader("lostcow.in"));
StringTokenizer st=new StringTokenizer(f.readLine());
int x=Integer.parseInt(st.nextToken());
int y=Integer.parseInt(st.nextToken());
int pos=x;
int steps=1;
int k=0;
int offset=925;
while(true) {
k=k+(Math.abs((pos-x)));//Put breakpoint here
pos=x+steps;
System.out.println(pos);
if(pos>(-offset)) {
//System.out.println(repeat(1000+offset+1,"*"));
//System.out.println(changen(pos+2,'X',repeat(1000+offset+1," ")));
}
if(pos>y&&x<y) {
break;
}
steps=steps*2;
pos=x-steps;
k=k+(Math.abs((pos-x)));
System.out.println(pos);
if(pos>(-offset)) {
//System.out.println(repeat(1000+offset+1,"*"));
//System.out.println(changen(pos+2,'X',repeat(1000+offset+1," ")));
}
if(pos<y&&y<x) {
break;
}
steps=steps*2;
}
System.out.println(k);
PrintWriter pw=new PrintWriter(new FileWriter("lostcow.out"));
pw.println(k);
pw.close();
f.close();
}
}