This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A380378 #11 Jun 11 2025 09:30:07 %S A380378 1,2,2,2,2,2,3,3,2,3,3,3,3,3,3,4,4,4,3,3,4,4,4,4,4,3,4,4,5,5,4,5,4,4, %T A380378 4,5,5,5,4,5,5,4,4,5,5,6,6,4,5,6,5,4,5,5,6,6,6,5,5,6,6,5,5,5,6,6,7,7, %U A380378 6,6,6,7,6,5,5,6,6,7,7,7,6,6,6,7,7,6,5,6,6,7,7 %N A380378 Triangle read by rows: T(n,k) is the minimum number of total votes needed for one party to win if there are n voters divided into k balanced districts, 1 <= k <= n. %C A380378 See A380377 for further details. %C A380378 It is never optimal to have any supporters in a losing district or to win a district with a greater margin than necessary. This implies that, in any optimal strategy, any district of size m should have 0, m/2, (m+1)/2, or m/2+1 supporters. If k is odd, the optimal strategy is to win the (k+1)/2 smallest districts. If k is even and n/k is an odd integer, the best strategy is to win k/2+1 districts (all districts have n/k voters in this case). If k is even and n/k is not an odd integer, the best strategy is to draw one of the even districts and win the k/2 smallest remaining districts. %H A380378 Pontus von Brömssen, <a href="/A380378/b380378.txt">Table of n, a(n) for n = 1..5050</a> (first 100 rows) %H A380378 Pontus von Brömssen, <a href="/A380378/a380378.png">Illustration for row n=100000</a>. %e A380378 Triangle begins: %e A380378 n\k| 1 2 3 4 5 6 7 8 9 10 11 12 %e A380378 ---+----------------------------------- %e A380378 1 | 1 %e A380378 2 | 2 2 %e A380378 3 | 2 2 2 %e A380378 4 | 3 3 2 3 %e A380378 5 | 3 3 3 3 3 %e A380378 6 | 4 4 4 3 3 4 %e A380378 7 | 4 4 4 4 3 4 4 %e A380378 8 | 5 5 4 5 4 4 4 5 %e A380378 9 | 5 5 4 5 5 4 4 5 5 %e A380378 10 | 6 6 4 5 6 5 4 5 5 6 %e A380378 11 | 6 6 5 5 6 6 5 5 5 6 6 %e A380378 12 | 7 7 6 6 6 7 6 5 5 6 6 7 %o A380378 (Python) %o A380378 def A380378(n,k): %o A380378 q,r = divmod(n,k) %o A380378 q2,rq = divmod(q,2) %o A380378 k2,rk = divmod(k,2) %o A380378 x = (k2+1)*(q2+1) %o A380378 if 2*r<k: x -= rk==0 and rq==0 %o A380378 else: %o A380378 if rq==1: x += r-k2+1-rk %o A380378 x += rk-1 %o A380378 return x %Y A380378 Cf. A380377 (row minima), A380379, A380380, A380381, A380382, A380383. %K A380378 nonn,tabl %O A380378 1,2 %A A380378 _Pontus von Brömssen_, Jan 24 2025