Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigInteger;
- import java.io.*;
- import java.util.HashSet;
- import java.util.Set;
- class FinalModifierTest {
- public static void main(String[] args) {
- int mx=1000001;
- int[] v = new int[mx];
- BigInteger m=BigInteger.valueOf(mx);
- BigInteger m1=BigInteger.valueOf(1);
- BigInteger m2=BigInteger.valueOf(2);
- BigInteger m3=BigInteger.valueOf(3);
- v[1]=1;
- for(int i=2;i<mx;++i)
- v[i]=0;
- for(int i=2;i<mx;++i)
- if(v[i]==0)
- {
- BigInteger a=BigInteger.valueOf(i);
- int x=0;
- while(a.compareTo(m)>-1 || v[a.intValue()]==0)
- {
- if(a.testBit(0))
- {
- a=a.multiply(m3);
- a=a.add(m1);
- }
- else
- {
- a=a.divide(m2);
- }
- x=x+1;
- }
- v[i]=v[a.intValue()]+x;
- a=BigInteger.valueOf(i);
- while(a.compareTo(m)>-1 || v[a.intValue()]==0)
- {
- if(a.testBit(0))
- {
- a=a.multiply(m3);
- a=a.add(m1);
- }
- else
- {
- a=a.divide(m2);
- }
- if(a.intValue()<mx)
- {
- v[a.intValue()]=x;
- }
- x=x-1;
- }
- }
- int res=0,res2=0;
- for(int i=2;i<mx;++i)
- if(v[i]>res)
- {
- res=v[i];
- res2=i;
- }
- System.out.println(res2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment