没啥可以优化的,送分题
package Interview2017.wangyi.No3;
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int num = in.nextInt();
int steps = 0;
int pre = 0,next = 1,temp = -1;
while(next < num){
temp = pre+next;
pre = next;
next = temp;
}
steps = ((num - pre) < (next - num)) ? (num-pre) : (next-num);
System.out.println(steps);
}
}