import java.util.*;
public class ilo {
public static List[] lista;
public static List listaout;
public static int fibI(int n) {
int elementA = 0;
int elementB = 1;
int wynik = 0;
int ls;
lista[0].add(new Integer(elementA));
lista[0].add(new Integer(elementB));
if (n < 2) return n;
for(int i = 2; i <= n; i++){
ls = lista.length;
wynik = elementA + elementB;
elementA = elementB;
elementB = wynik;
for (int j = 0; j < ls; j++) {
if ((lista[j].size() > 0) && (((Integer)lista[j].get(0)).intValue() % wynik) == 0)
lista[j].add(new Integer(((Integer)lista[j].get(0)).intValue() / wynik));
int lsi = lista[j].size();
for (int k = 1;k< lsi;k++) {
if (((Integer)lista[j].get(k)).intValue() == wynik) {
listaout.set(j,new String("TAK"));
lista[j].clear();
break;
}
}
}
}
return wynik;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int max = 0;
lista = new List[n];
listaout = new ArrayList(n);
for (int nn=0;nn<n;nn++) {
lista[nn] = new ArrayList();
listaout.add(new String("NIE"));
lista[nn].add(new Integer(sc.nextInt()));
if (max < ((Integer)(lista[nn].get(0))).intValue())
max = ((Integer)(lista[nn].get(0))).intValue();
}
fibI(max);
for (int nn=0;nn<n;nn++)
System.out.println(listaout.get(nn));
sc.close();
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import java.util.*; public class ilo { public static List[] lista; public static List listaout; public static int fibI(int n) { int elementA = 0; int elementB = 1; int wynik = 0; int ls; lista[0].add(new Integer(elementA)); lista[0].add(new Integer(elementB)); if (n < 2) return n; for(int i = 2; i <= n; i++){ ls = lista.length; wynik = elementA + elementB; elementA = elementB; elementB = wynik; for (int j = 0; j < ls; j++) { if ((lista[j].size() > 0) && (((Integer)lista[j].get(0)).intValue() % wynik) == 0) lista[j].add(new Integer(((Integer)lista[j].get(0)).intValue() / wynik)); int lsi = lista[j].size(); for (int k = 1;k< lsi;k++) { if (((Integer)lista[j].get(k)).intValue() == wynik) { listaout.set(j,new String("TAK")); lista[j].clear(); break; } } } } return wynik; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int max = 0; lista = new List[n]; listaout = new ArrayList(n); for (int nn=0;nn<n;nn++) { lista[nn] = new ArrayList(); listaout.add(new String("NIE")); lista[nn].add(new Integer(sc.nextInt())); if (max < ((Integer)(lista[nn].get(0))).intValue()) max = ((Integer)(lista[nn].get(0))).intValue(); } fibI(max); for (int nn=0;nn<n;nn++) System.out.println(listaout.get(nn)); sc.close(); } } |
English