import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
String m="";
ArrayList<BigInteger> bg=new ArrayList<BigInteger>();
StringBuilder str=new StringBuilder("10");
for(int i=0;i<100;i++){
str.append('0');
}
BigInteger max=new BigInteger(str.toString());
BigInteger b1=BigInteger.ONE,b2=BigInteger.valueOf(2);
bg.add(b1);
bg.add(b2);
while(b1.compareTo(max)==-1){
BigInteger temp=b1.add(b2);
b1=b2;
b2=temp;
bg.add(temp);
}
while((m=br.readLine())!=null){
int counter=0;
String x[]=m.split(" ");
if("0".equals(x[0]) && "0".equals(x[1]))
break;
b1=new BigInteger(x[0]);
b2=new BigInteger(x[1]);
BigInteger bigger=b1.max(b2);
BigInteger smaller=b1.min(b2);
for(int i=0;i<bg.size();i++){
if(bg.get(i).compareTo(smaller)!=-1
&& bg.get(i).compareTo(bigger)!=1){
counter++;
}
}
sb.append(counter).append("\n");
}
System.out.print(sb);
}
static int LCS(String m,String n,int[][] arr){
arr=new int[m.length()+1][n.length()+1];
for(int i=0;i<m.length()+1;i++)
arr[i][0]=0;
for(int i=0;i<n.length()+1;i++)
arr[0][i]=0;
for(int i=0;i<m.length();i++){
for(int j=0;j<n.length();j++){
if(m.charAt(i)==n.charAt(j))
arr[i+1][j+1]=arr[i][j]+1;
else
arr[i+1][j+1]=Math.max(arr[i+1][j],arr[i][j+1]);
}
}
return arr[m.length()][n.length()];
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
String m="";
ArrayList<BigInteger> bg=new ArrayList<BigInteger>();
StringBuilder str=new StringBuilder("10");
for(int i=0;i<100;i++){
str.append('0');
}
BigInteger max=new BigInteger(str.toString());
BigInteger b1=BigInteger.ONE,b2=BigInteger.valueOf(2);
bg.add(b1);
bg.add(b2);
while(b1.compareTo(max)==-1){
BigInteger temp=b1.add(b2);
b1=b2;
b2=temp;
bg.add(temp);
}
while((m=br.readLine())!=null){
int counter=0;
String x[]=m.split(" ");
if("0".equals(x[0]) && "0".equals(x[1]))
break;
b1=new BigInteger(x[0]);
b2=new BigInteger(x[1]);
BigInteger bigger=b1.max(b2);
BigInteger smaller=b1.min(b2);
for(int i=0;i<bg.size();i++){
if(bg.get(i).compareTo(smaller)!=-1
&& bg.get(i).compareTo(bigger)!=1){
counter++;
}
}
sb.append(counter).append("\n");
}
System.out.print(sb);
}
static int LCS(String m,String n,int[][] arr){
arr=new int[m.length()+1][n.length()+1];
for(int i=0;i<m.length()+1;i++)
arr[i][0]=0;
for(int i=0;i<n.length()+1;i++)
arr[0][i]=0;
for(int i=0;i<m.length();i++){
for(int j=0;j<n.length();j++){
if(m.charAt(i)==n.charAt(j))
arr[i+1][j+1]=arr[i][j]+1;
else
arr[i+1][j+1]=Math.max(arr[i+1][j],arr[i][j+1]);
}
}
return arr[m.length()][n.length()];
}
}
No comments:
Post a Comment