tobogganSe connecter

louise

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

11 lignes · 526 octetsBrut · Historique
1public class Trees {
2 record Tree(Tree l, Tree r, long v) {}
3 static Tree make(int d, long v) { return d == 0 ? new Tree(null, null, v) : new Tree(make(d - 1, v), make(d - 1, v), 0); }
4 static long check(Tree t) { return t.l() == null ? t.v() % 2 : 1 + check(t.l()) + check(t.r()); }
5 public static void main(String[] a) {
6 long acc = 0;
7 for (int d = 4; d <= 16; d += 2)
8 for (long i = 1; i <= (1L << (16 - d + 4)); i++) acc += check(make(d, i));
9 System.out.println(acc);
10 }
11}