|
|
back to boardJAVA import java.util.Scanner; public class Kb_numb { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int i,n,k; int[] F=new int[20]; Scanner in=new Scanner(System.in); n=in.nextInt(); k=in.nextInt(); F[0]=k-1; F[1]=k*F[0]; for(i=2;i<n;i++){ F[i]=(F[i-1]+F[i-2])*(k-1); } System.out.print(F[n-1]); } } |
|
|