Source ¶
import java.util.Scanner; public class granma { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int d = sc.nextInt(); int [] num = new int[d+1]; num[0]=1;num[1]=1; for(int i=2; i<num.length; i++){ num[i] = num[i-1]+num[i-2]; } int k = sc.nextInt(); find(num[d-3],num[d-2],k); } private static void find(int x, int y, int k) { int i=1; while(true){ if((k-x*i)%y==0){ System.out.println(i+"\n"+(k-x*i)/y); System.exit(0); } i++; } } }