diff --git a/solutions/beecrowd/1032/1032.py b/solutions/beecrowd/1032/1032.py new file mode 100644 index 00000000..76609b6f --- /dev/null +++ b/solutions/beecrowd/1032/1032.py @@ -0,0 +1,70 @@ +import sys +from math import sqrt + +sys.setrecursionlimit(3505) + +primes = { + 2: 3, + 3: 5, + 5: 7, + 7: 11, + 11: 13, + 13: 17, + 17: 19, + 19: 23, + 23: 29, + 29: 31, + 31: 37, + 37: 41, + 41: 43, + 43: 47, + 47: 53, + 53: 59, + 59: 61, + 61: 67, + 67: 71, + 71: 73, + 73: 79, + 79: 83, + 83: 89, + 89: 97, + 97: 101, +} + + +def is_prime(number): + if number == 2: + return True + if number <= 1 or number % 2 == 0: + return False + for divisor in range(3, int(sqrt(number)) + 1, 2): + if number % divisor == 0: + return False + return True + + +def next_prime(number): + if number in primes: + return primes[number] + + next = number + 1 + while not is_prime(next): + next += 1 + primes[number] = next + + return primes[number] + + +def josephus(n, k=2) -> int: + if n == 1: + return 1 + return ((josephus(n - 1, next_prime(k)) + k - 1) % n) + 1 + + +for line in sys.stdin: + n = int(line) + + if n == 0: + break + + print(josephus(n)) diff --git a/solutions/beecrowd/1032/generate_in.sh b/solutions/beecrowd/1032/generate_in.sh new file mode 100755 index 00000000..333b6428 --- /dev/null +++ b/solutions/beecrowd/1032/generate_in.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -euo pipefail + +seq 3501 +echo 0 diff --git a/solutions/beecrowd/1032/in.txt b/solutions/beecrowd/1032/in.txt new file mode 100644 index 00000000..0c913a33 --- /dev/null +++ b/solutions/beecrowd/1032/in.txt @@ -0,0 +1,3502 @@ +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 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 +770 +771 +772 +773 +774 +775 +776 +777 +778 +779 +780 +781 +782 +783 +784 +785 +786 +787 +788 +789 +790 +791 +792 +793 +794 +795 +796 +797 +798 +799 +800 +801 +802 +803 +804 +805 +806 +807 +808 +809 +810 +811 +812 +813 +814 +815 +816 +817 +818 +819 +820 +821 +822 +823 +824 +825 +826 +827 +828 +829 +830 +831 +832 +833 +834 +835 +836 +837 +838 +839 +840 +841 +842 +843 +844 +845 +846 +847 +848 +849 +850 +851 +852 +853 +854 +855 +856 +857 +858 +859 +860 +861 +862 +863 +864 +865 +866 +867 +868 +869 +870 +871 +872 +873 +874 +875 +876 +877 +878 +879 +880 +881 +882 +883 +884 +885 +886 +887 +888 +889 +890 +891 +892 +893 +894 +895 +896 +897 +898 +899 +900 +901 +902 +903 +904 +905 +906 +907 +908 +909 +910 +911 +912 +913 +914 +915 +916 +917 +918 +919 +920 +921 +922 +923 +924 +925 +926 +927 +928 +929 +930 +931 +932 +933 +934 +935 +936 +937 +938 +939 +940 +941 +942 +943 +944 +945 +946 +947 +948 +949 +950 +951 +952 +953 +954 +955 +956 +957 +958 +959 +960 +961 +962 +963 +964 +965 +966 +967 +968 +969 +970 +971 +972 +973 +974 +975 +976 +977 +978 +979 +980 +981 +982 +983 +984 +985 +986 +987 +988 +989 +990 +991 +992 +993 +994 +995 +996 +997 +998 +999 +1000 +1001 +1002 +1003 +1004 +1005 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1022 +1023 +1024 +1025 +1026 +1027 +1028 +1029 +1030 +1031 +1032 +1033 +1034 +1035 +1036 +1037 +1038 +1039 +1040 +1041 +1042 +1043 +1044 +1045 +1046 +1047 +1048 +1049 +1050 +1051 +1052 +1053 +1054 +1055 +1056 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 +1071 +1072 +1073 +1074 +1075 +1076 +1077 +1078 +1079 +1080 +1081 +1082 +1083 +1084 +1085 +1086 +1087 +1088 +1089 +1090 +1091 +1092 +1093 +1094 +1095 +1096 +1097 +1098 +1099 +1100 +1101 +1102 +1103 +1104 +1105 +1106 +1107 +1108 +1109 +1110 +1111 +1112 +1113 +1114 +1115 +1116 +1117 +1118 +1119 +1120 +1121 +1122 +1123 +1124 +1125 +1126 +1127 +1128 +1129 +1130 +1131 +1132 +1133 +1134 +1135 +1136 +1137 +1138 +1139 +1140 +1141 +1142 +1143 +1144 +1145 +1146 +1147 +1148 +1149 +1150 +1151 +1152 +1153 +1154 +1155 +1156 +1157 +1158 +1159 +1160 +1161 +1162 +1163 +1164 +1165 +1166 +1167 +1168 +1169 +1170 +1171 +1172 +1173 +1174 +1175 +1176 +1177 +1178 +1179 +1180 +1181 +1182 +1183 +1184 +1185 +1186 +1187 +1188 +1189 +1190 +1191 +1192 +1193 +1194 +1195 +1196 +1197 +1198 +1199 +1200 +1201 +1202 +1203 +1204 +1205 +1206 +1207 +1208 +1209 +1210 +1211 +1212 +1213 +1214 +1215 +1216 +1217 +1218 +1219 +1220 +1221 +1222 +1223 +1224 +1225 +1226 +1227 +1228 +1229 +1230 +1231 +1232 +1233 +1234 +1235 +1236 +1237 +1238 +1239 +1240 +1241 +1242 +1243 +1244 +1245 +1246 +1247 +1248 +1249 +1250 +1251 +1252 +1253 +1254 +1255 +1256 +1257 +1258 +1259 +1260 +1261 +1262 +1263 +1264 +1265 +1266 +1267 +1268 +1269 +1270 +1271 +1272 +1273 +1274 +1275 +1276 +1277 +1278 +1279 +1280 +1281 +1282 +1283 +1284 +1285 +1286 +1287 +1288 +1289 +1290 +1291 +1292 +1293 +1294 +1295 +1296 +1297 +1298 +1299 +1300 +1301 +1302 +1303 +1304 +1305 +1306 +1307 +1308 +1309 +1310 +1311 +1312 +1313 +1314 +1315 +1316 +1317 +1318 +1319 +1320 +1321 +1322 +1323 +1324 +1325 +1326 +1327 +1328 +1329 +1330 +1331 +1332 +1333 +1334 +1335 +1336 +1337 +1338 +1339 +1340 +1341 +1342 +1343 +1344 +1345 +1346 +1347 +1348 +1349 +1350 +1351 +1352 +1353 +1354 +1355 +1356 +1357 +1358 +1359 +1360 +1361 +1362 +1363 +1364 +1365 +1366 +1367 +1368 +1369 +1370 +1371 +1372 +1373 +1374 +1375 +1376 +1377 +1378 +1379 +1380 +1381 +1382 +1383 +1384 +1385 +1386 +1387 +1388 +1389 +1390 +1391 +1392 +1393 +1394 +1395 +1396 +1397 +1398 +1399 +1400 +1401 +1402 +1403 +1404 +1405 +1406 +1407 +1408 +1409 +1410 +1411 +1412 +1413 +1414 +1415 +1416 +1417 +1418 +1419 +1420 +1421 +1422 +1423 +1424 +1425 +1426 +1427 +1428 +1429 +1430 +1431 +1432 +1433 +1434 +1435 +1436 +1437 +1438 +1439 +1440 +1441 +1442 +1443 +1444 +1445 +1446 +1447 +1448 +1449 +1450 +1451 +1452 +1453 +1454 +1455 +1456 +1457 +1458 +1459 +1460 +1461 +1462 +1463 +1464 +1465 +1466 +1467 +1468 +1469 +1470 +1471 +1472 +1473 +1474 +1475 +1476 +1477 +1478 +1479 +1480 +1481 +1482 +1483 +1484 +1485 +1486 +1487 +1488 +1489 +1490 +1491 +1492 +1493 +1494 +1495 +1496 +1497 +1498 +1499 +1500 +1501 +1502 +1503 +1504 +1505 +1506 +1507 +1508 +1509 +1510 +1511 +1512 +1513 +1514 +1515 +1516 +1517 +1518 +1519 +1520 +1521 +1522 +1523 +1524 +1525 +1526 +1527 +1528 +1529 +1530 +1531 +1532 +1533 +1534 +1535 +1536 +1537 +1538 +1539 +1540 +1541 +1542 +1543 +1544 +1545 +1546 +1547 +1548 +1549 +1550 +1551 +1552 +1553 +1554 +1555 +1556 +1557 +1558 +1559 +1560 +1561 +1562 +1563 +1564 +1565 +1566 +1567 +1568 +1569 +1570 +1571 +1572 +1573 +1574 +1575 +1576 +1577 +1578 +1579 +1580 +1581 +1582 +1583 +1584 +1585 +1586 +1587 +1588 +1589 +1590 +1591 +1592 +1593 +1594 +1595 +1596 +1597 +1598 +1599 +1600 +1601 +1602 +1603 +1604 +1605 +1606 +1607 +1608 +1609 +1610 +1611 +1612 +1613 +1614 +1615 +1616 +1617 +1618 +1619 +1620 +1621 +1622 +1623 +1624 +1625 +1626 +1627 +1628 +1629 +1630 +1631 +1632 +1633 +1634 +1635 +1636 +1637 +1638 +1639 +1640 +1641 +1642 +1643 +1644 +1645 +1646 +1647 +1648 +1649 +1650 +1651 +1652 +1653 +1654 +1655 +1656 +1657 +1658 +1659 +1660 +1661 +1662 +1663 +1664 +1665 +1666 +1667 +1668 +1669 +1670 +1671 +1672 +1673 +1674 +1675 +1676 +1677 +1678 +1679 +1680 +1681 +1682 +1683 +1684 +1685 +1686 +1687 +1688 +1689 +1690 +1691 +1692 +1693 +1694 +1695 +1696 +1697 +1698 +1699 +1700 +1701 +1702 +1703 +1704 +1705 +1706 +1707 +1708 +1709 +1710 +1711 +1712 +1713 +1714 +1715 +1716 +1717 +1718 +1719 +1720 +1721 +1722 +1723 +1724 +1725 +1726 +1727 +1728 +1729 +1730 +1731 +1732 +1733 +1734 +1735 +1736 +1737 +1738 +1739 +1740 +1741 +1742 +1743 +1744 +1745 +1746 +1747 +1748 +1749 +1750 +1751 +1752 +1753 +1754 +1755 +1756 +1757 +1758 +1759 +1760 +1761 +1762 +1763 +1764 +1765 +1766 +1767 +1768 +1769 +1770 +1771 +1772 +1773 +1774 +1775 +1776 +1777 +1778 +1779 +1780 +1781 +1782 +1783 +1784 +1785 +1786 +1787 +1788 +1789 +1790 +1791 +1792 +1793 +1794 +1795 +1796 +1797 +1798 +1799 +1800 +1801 +1802 +1803 +1804 +1805 +1806 +1807 +1808 +1809 +1810 +1811 +1812 +1813 +1814 +1815 +1816 +1817 +1818 +1819 +1820 +1821 +1822 +1823 +1824 +1825 +1826 +1827 +1828 +1829 +1830 +1831 +1832 +1833 +1834 +1835 +1836 +1837 +1838 +1839 +1840 +1841 +1842 +1843 +1844 +1845 +1846 +1847 +1848 +1849 +1850 +1851 +1852 +1853 +1854 +1855 +1856 +1857 +1858 +1859 +1860 +1861 +1862 +1863 +1864 +1865 +1866 +1867 +1868 +1869 +1870 +1871 +1872 +1873 +1874 +1875 +1876 +1877 +1878 +1879 +1880 +1881 +1882 +1883 +1884 +1885 +1886 +1887 +1888 +1889 +1890 +1891 +1892 +1893 +1894 +1895 +1896 +1897 +1898 +1899 +1900 +1901 +1902 +1903 +1904 +1905 +1906 +1907 +1908 +1909 +1910 +1911 +1912 +1913 +1914 +1915 +1916 +1917 +1918 +1919 +1920 +1921 +1922 +1923 +1924 +1925 +1926 +1927 +1928 +1929 +1930 +1931 +1932 +1933 +1934 +1935 +1936 +1937 +1938 +1939 +1940 +1941 +1942 +1943 +1944 +1945 +1946 +1947 +1948 +1949 +1950 +1951 +1952 +1953 +1954 +1955 +1956 +1957 +1958 +1959 +1960 +1961 +1962 +1963 +1964 +1965 +1966 +1967 +1968 +1969 +1970 +1971 +1972 +1973 +1974 +1975 +1976 +1977 +1978 +1979 +1980 +1981 +1982 +1983 +1984 +1985 +1986 +1987 +1988 +1989 +1990 +1991 +1992 +1993 +1994 +1995 +1996 +1997 +1998 +1999 +2000 +2001 +2002 +2003 +2004 +2005 +2006 +2007 +2008 +2009 +2010 +2011 +2012 +2013 +2014 +2015 +2016 +2017 +2018 +2019 +2020 +2021 +2022 +2023 +2024 +2025 +2026 +2027 +2028 +2029 +2030 +2031 +2032 +2033 +2034 +2035 +2036 +2037 +2038 +2039 +2040 +2041 +2042 +2043 +2044 +2045 +2046 +2047 +2048 +2049 +2050 +2051 +2052 +2053 +2054 +2055 +2056 +2057 +2058 +2059 +2060 +2061 +2062 +2063 +2064 +2065 +2066 +2067 +2068 +2069 +2070 +2071 +2072 +2073 +2074 +2075 +2076 +2077 +2078 +2079 +2080 +2081 +2082 +2083 +2084 +2085 +2086 +2087 +2088 +2089 +2090 +2091 +2092 +2093 +2094 +2095 +2096 +2097 +2098 +2099 +2100 +2101 +2102 +2103 +2104 +2105 +2106 +2107 +2108 +2109 +2110 +2111 +2112 +2113 +2114 +2115 +2116 +2117 +2118 +2119 +2120 +2121 +2122 +2123 +2124 +2125 +2126 +2127 +2128 +2129 +2130 +2131 +2132 +2133 +2134 +2135 +2136 +2137 +2138 +2139 +2140 +2141 +2142 +2143 +2144 +2145 +2146 +2147 +2148 +2149 +2150 +2151 +2152 +2153 +2154 +2155 +2156 +2157 +2158 +2159 +2160 +2161 +2162 +2163 +2164 +2165 +2166 +2167 +2168 +2169 +2170 +2171 +2172 +2173 +2174 +2175 +2176 +2177 +2178 +2179 +2180 +2181 +2182 +2183 +2184 +2185 +2186 +2187 +2188 +2189 +2190 +2191 +2192 +2193 +2194 +2195 +2196 +2197 +2198 +2199 +2200 +2201 +2202 +2203 +2204 +2205 +2206 +2207 +2208 +2209 +2210 +2211 +2212 +2213 +2214 +2215 +2216 +2217 +2218 +2219 +2220 +2221 +2222 +2223 +2224 +2225 +2226 +2227 +2228 +2229 +2230 +2231 +2232 +2233 +2234 +2235 +2236 +2237 +2238 +2239 +2240 +2241 +2242 +2243 +2244 +2245 +2246 +2247 +2248 +2249 +2250 +2251 +2252 +2253 +2254 +2255 +2256 +2257 +2258 +2259 +2260 +2261 +2262 +2263 +2264 +2265 +2266 +2267 +2268 +2269 +2270 +2271 +2272 +2273 +2274 +2275 +2276 +2277 +2278 +2279 +2280 +2281 +2282 +2283 +2284 +2285 +2286 +2287 +2288 +2289 +2290 +2291 +2292 +2293 +2294 +2295 +2296 +2297 +2298 +2299 +2300 +2301 +2302 +2303 +2304 +2305 +2306 +2307 +2308 +2309 +2310 +2311 +2312 +2313 +2314 +2315 +2316 +2317 +2318 +2319 +2320 +2321 +2322 +2323 +2324 +2325 +2326 +2327 +2328 +2329 +2330 +2331 +2332 +2333 +2334 +2335 +2336 +2337 +2338 +2339 +2340 +2341 +2342 +2343 +2344 +2345 +2346 +2347 +2348 +2349 +2350 +2351 +2352 +2353 +2354 +2355 +2356 +2357 +2358 +2359 +2360 +2361 +2362 +2363 +2364 +2365 +2366 +2367 +2368 +2369 +2370 +2371 +2372 +2373 +2374 +2375 +2376 +2377 +2378 +2379 +2380 +2381 +2382 +2383 +2384 +2385 +2386 +2387 +2388 +2389 +2390 +2391 +2392 +2393 +2394 +2395 +2396 +2397 +2398 +2399 +2400 +2401 +2402 +2403 +2404 +2405 +2406 +2407 +2408 +2409 +2410 +2411 +2412 +2413 +2414 +2415 +2416 +2417 +2418 +2419 +2420 +2421 +2422 +2423 +2424 +2425 +2426 +2427 +2428 +2429 +2430 +2431 +2432 +2433 +2434 +2435 +2436 +2437 +2438 +2439 +2440 +2441 +2442 +2443 +2444 +2445 +2446 +2447 +2448 +2449 +2450 +2451 +2452 +2453 +2454 +2455 +2456 +2457 +2458 +2459 +2460 +2461 +2462 +2463 +2464 +2465 +2466 +2467 +2468 +2469 +2470 +2471 +2472 +2473 +2474 +2475 +2476 +2477 +2478 +2479 +2480 +2481 +2482 +2483 +2484 +2485 +2486 +2487 +2488 +2489 +2490 +2491 +2492 +2493 +2494 +2495 +2496 +2497 +2498 +2499 +2500 +2501 +2502 +2503 +2504 +2505 +2506 +2507 +2508 +2509 +2510 +2511 +2512 +2513 +2514 +2515 +2516 +2517 +2518 +2519 +2520 +2521 +2522 +2523 +2524 +2525 +2526 +2527 +2528 +2529 +2530 +2531 +2532 +2533 +2534 +2535 +2536 +2537 +2538 +2539 +2540 +2541 +2542 +2543 +2544 +2545 +2546 +2547 +2548 +2549 +2550 +2551 +2552 +2553 +2554 +2555 +2556 +2557 +2558 +2559 +2560 +2561 +2562 +2563 +2564 +2565 +2566 +2567 +2568 +2569 +2570 +2571 +2572 +2573 +2574 +2575 +2576 +2577 +2578 +2579 +2580 +2581 +2582 +2583 +2584 +2585 +2586 +2587 +2588 +2589 +2590 +2591 +2592 +2593 +2594 +2595 +2596 +2597 +2598 +2599 +2600 +2601 +2602 +2603 +2604 +2605 +2606 +2607 +2608 +2609 +2610 +2611 +2612 +2613 +2614 +2615 +2616 +2617 +2618 +2619 +2620 +2621 +2622 +2623 +2624 +2625 +2626 +2627 +2628 +2629 +2630 +2631 +2632 +2633 +2634 +2635 +2636 +2637 +2638 +2639 +2640 +2641 +2642 +2643 +2644 +2645 +2646 +2647 +2648 +2649 +2650 +2651 +2652 +2653 +2654 +2655 +2656 +2657 +2658 +2659 +2660 +2661 +2662 +2663 +2664 +2665 +2666 +2667 +2668 +2669 +2670 +2671 +2672 +2673 +2674 +2675 +2676 +2677 +2678 +2679 +2680 +2681 +2682 +2683 +2684 +2685 +2686 +2687 +2688 +2689 +2690 +2691 +2692 +2693 +2694 +2695 +2696 +2697 +2698 +2699 +2700 +2701 +2702 +2703 +2704 +2705 +2706 +2707 +2708 +2709 +2710 +2711 +2712 +2713 +2714 +2715 +2716 +2717 +2718 +2719 +2720 +2721 +2722 +2723 +2724 +2725 +2726 +2727 +2728 +2729 +2730 +2731 +2732 +2733 +2734 +2735 +2736 +2737 +2738 +2739 +2740 +2741 +2742 +2743 +2744 +2745 +2746 +2747 +2748 +2749 +2750 +2751 +2752 +2753 +2754 +2755 +2756 +2757 +2758 +2759 +2760 +2761 +2762 +2763 +2764 +2765 +2766 +2767 +2768 +2769 +2770 +2771 +2772 +2773 +2774 +2775 +2776 +2777 +2778 +2779 +2780 +2781 +2782 +2783 +2784 +2785 +2786 +2787 +2788 +2789 +2790 +2791 +2792 +2793 +2794 +2795 +2796 +2797 +2798 +2799 +2800 +2801 +2802 +2803 +2804 +2805 +2806 +2807 +2808 +2809 +2810 +2811 +2812 +2813 +2814 +2815 +2816 +2817 +2818 +2819 +2820 +2821 +2822 +2823 +2824 +2825 +2826 +2827 +2828 +2829 +2830 +2831 +2832 +2833 +2834 +2835 +2836 +2837 +2838 +2839 +2840 +2841 +2842 +2843 +2844 +2845 +2846 +2847 +2848 +2849 +2850 +2851 +2852 +2853 +2854 +2855 +2856 +2857 +2858 +2859 +2860 +2861 +2862 +2863 +2864 +2865 +2866 +2867 +2868 +2869 +2870 +2871 +2872 +2873 +2874 +2875 +2876 +2877 +2878 +2879 +2880 +2881 +2882 +2883 +2884 +2885 +2886 +2887 +2888 +2889 +2890 +2891 +2892 +2893 +2894 +2895 +2896 +2897 +2898 +2899 +2900 +2901 +2902 +2903 +2904 +2905 +2906 +2907 +2908 +2909 +2910 +2911 +2912 +2913 +2914 +2915 +2916 +2917 +2918 +2919 +2920 +2921 +2922 +2923 +2924 +2925 +2926 +2927 +2928 +2929 +2930 +2931 +2932 +2933 +2934 +2935 +2936 +2937 +2938 +2939 +2940 +2941 +2942 +2943 +2944 +2945 +2946 +2947 +2948 +2949 +2950 +2951 +2952 +2953 +2954 +2955 +2956 +2957 +2958 +2959 +2960 +2961 +2962 +2963 +2964 +2965 +2966 +2967 +2968 +2969 +2970 +2971 +2972 +2973 +2974 +2975 +2976 +2977 +2978 +2979 +2980 +2981 +2982 +2983 +2984 +2985 +2986 +2987 +2988 +2989 +2990 +2991 +2992 +2993 +2994 +2995 +2996 +2997 +2998 +2999 +3000 +3001 +3002 +3003 +3004 +3005 +3006 +3007 +3008 +3009 +3010 +3011 +3012 +3013 +3014 +3015 +3016 +3017 +3018 +3019 +3020 +3021 +3022 +3023 +3024 +3025 +3026 +3027 +3028 +3029 +3030 +3031 +3032 +3033 +3034 +3035 +3036 +3037 +3038 +3039 +3040 +3041 +3042 +3043 +3044 +3045 +3046 +3047 +3048 +3049 +3050 +3051 +3052 +3053 +3054 +3055 +3056 +3057 +3058 +3059 +3060 +3061 +3062 +3063 +3064 +3065 +3066 +3067 +3068 +3069 +3070 +3071 +3072 +3073 +3074 +3075 +3076 +3077 +3078 +3079 +3080 +3081 +3082 +3083 +3084 +3085 +3086 +3087 +3088 +3089 +3090 +3091 +3092 +3093 +3094 +3095 +3096 +3097 +3098 +3099 +3100 +3101 +3102 +3103 +3104 +3105 +3106 +3107 +3108 +3109 +3110 +3111 +3112 +3113 +3114 +3115 +3116 +3117 +3118 +3119 +3120 +3121 +3122 +3123 +3124 +3125 +3126 +3127 +3128 +3129 +3130 +3131 +3132 +3133 +3134 +3135 +3136 +3137 +3138 +3139 +3140 +3141 +3142 +3143 +3144 +3145 +3146 +3147 +3148 +3149 +3150 +3151 +3152 +3153 +3154 +3155 +3156 +3157 +3158 +3159 +3160 +3161 +3162 +3163 +3164 +3165 +3166 +3167 +3168 +3169 +3170 +3171 +3172 +3173 +3174 +3175 +3176 +3177 +3178 +3179 +3180 +3181 +3182 +3183 +3184 +3185 +3186 +3187 +3188 +3189 +3190 +3191 +3192 +3193 +3194 +3195 +3196 +3197 +3198 +3199 +3200 +3201 +3202 +3203 +3204 +3205 +3206 +3207 +3208 +3209 +3210 +3211 +3212 +3213 +3214 +3215 +3216 +3217 +3218 +3219 +3220 +3221 +3222 +3223 +3224 +3225 +3226 +3227 +3228 +3229 +3230 +3231 +3232 +3233 +3234 +3235 +3236 +3237 +3238 +3239 +3240 +3241 +3242 +3243 +3244 +3245 +3246 +3247 +3248 +3249 +3250 +3251 +3252 +3253 +3254 +3255 +3256 +3257 +3258 +3259 +3260 +3261 +3262 +3263 +3264 +3265 +3266 +3267 +3268 +3269 +3270 +3271 +3272 +3273 +3274 +3275 +3276 +3277 +3278 +3279 +3280 +3281 +3282 +3283 +3284 +3285 +3286 +3287 +3288 +3289 +3290 +3291 +3292 +3293 +3294 +3295 +3296 +3297 +3298 +3299 +3300 +3301 +3302 +3303 +3304 +3305 +3306 +3307 +3308 +3309 +3310 +3311 +3312 +3313 +3314 +3315 +3316 +3317 +3318 +3319 +3320 +3321 +3322 +3323 +3324 +3325 +3326 +3327 +3328 +3329 +3330 +3331 +3332 +3333 +3334 +3335 +3336 +3337 +3338 +3339 +3340 +3341 +3342 +3343 +3344 +3345 +3346 +3347 +3348 +3349 +3350 +3351 +3352 +3353 +3354 +3355 +3356 +3357 +3358 +3359 +3360 +3361 +3362 +3363 +3364 +3365 +3366 +3367 +3368 +3369 +3370 +3371 +3372 +3373 +3374 +3375 +3376 +3377 +3378 +3379 +3380 +3381 +3382 +3383 +3384 +3385 +3386 +3387 +3388 +3389 +3390 +3391 +3392 +3393 +3394 +3395 +3396 +3397 +3398 +3399 +3400 +3401 +3402 +3403 +3404 +3405 +3406 +3407 +3408 +3409 +3410 +3411 +3412 +3413 +3414 +3415 +3416 +3417 +3418 +3419 +3420 +3421 +3422 +3423 +3424 +3425 +3426 +3427 +3428 +3429 +3430 +3431 +3432 +3433 +3434 +3435 +3436 +3437 +3438 +3439 +3440 +3441 +3442 +3443 +3444 +3445 +3446 +3447 +3448 +3449 +3450 +3451 +3452 +3453 +3454 +3455 +3456 +3457 +3458 +3459 +3460 +3461 +3462 +3463 +3464 +3465 +3466 +3467 +3468 +3469 +3470 +3471 +3472 +3473 +3474 +3475 +3476 +3477 +3478 +3479 +3480 +3481 +3482 +3483 +3484 +3485 +3486 +3487 +3488 +3489 +3490 +3491 +3492 +3493 +3494 +3495 +3496 +3497 +3498 +3499 +3500 +3501 +0 diff --git a/solutions/beecrowd/1032/out.txt b/solutions/beecrowd/1032/out.txt new file mode 100644 index 00000000..f1754a22 --- /dev/null +++ b/solutions/beecrowd/1032/out.txt @@ -0,0 +1,3501 @@ +1 +1 +1 +4 +1 +4 +3 +8 +7 +1 +6 +12 +12 +3 +14 +16 +9 +7 +14 +3 +19 +14 +18 +16 +7 +1 +4 +18 +3 +15 +7 +13 +15 +18 +19 +4 +14 +3 +27 +31 +23 +15 +31 +33 +45 +42 +44 +30 +20 +16 +3 +22 +37 +24 +53 +42 +16 +22 +21 +60 +24 +35 +26 +43 +34 +38 +37 +56 +48 +46 +36 +45 +40 +25 +56 +46 +14 +36 +48 +67 +42 +37 +19 +6 +74 +35 +29 +22 +25 +82 +18 +82 +68 +38 +92 +95 +66 +40 +74 +60 +3 +70 +20 +62 +55 +97 +27 +20 +50 +27 +32 +9 +65 +35 +76 +29 +107 +73 +6 +95 +53 +21 +71 +54 +86 +81 +40 +60 +68 +44 +67 +55 +109 +64 +116 +114 +64 +50 +97 +94 +82 +102 +45 +45 +144 +45 +47 +43 +79 +76 +81 +82 +148 +54 +32 +117 +141 +30 +156 +122 +106 +106 +9 +34 +126 +67 +45 +9 +163 +25 +145 +66 +90 +138 +156 +33 +120 +19 +34 +79 +70 +176 +113 +98 +157 +127 +67 +54 +143 +59 +103 +70 +50 +179 +134 +8 +21 +161 +92 +140 +76 +18 +26 +37 +157 +13 +142 +186 +138 +107 +12 +114 +134 +19 +184 +144 +57 +139 +103 +178 +217 +92 +207 +150 +42 +145 +47 +81 +106 +135 +108 +45 +8 +193 +30 +35 +202 +32 +12 +240 +212 +230 +176 +53 +82 +96 +93 +243 +172 +195 +128 +3 +65 +117 +62 +6 +191 +111 +208 +181 +47 +47 +237 +91 +156 +108 +69 +90 +257 +262 +52 +103 +96 +156 +126 +12 +79 +152 +141 +72 +121 +49 +82 +46 +138 +220 +180 +275 +282 +217 +174 +87 +159 +72 +282 +262 +256 +53 +101 +278 +178 +95 +139 +211 +112 +267 +277 +225 +291 +50 +249 +176 +26 +104 +31 +64 +199 +103 +279 +21 +12 +111 +12 +292 +211 +246 +247 +39 +9 +282 +258 +170 +182 +199 +134 +86 +62 +303 +78 +171 +202 +248 +159 +192 +326 +298 +45 +235 +297 +344 +49 +110 +166 +151 +50 +334 +320 +217 +114 +332 +11 +91 +91 +64 +259 +240 +173 +92 +136 +76 +99 +226 +163 +90 +329 +249 +342 +3 +339 +103 +256 +362 +376 +362 +142 +88 +52 +64 +305 +177 +131 +372 +163 +295 +102 +355 +199 +130 +179 +264 +189 +196 +118 +370 +150 +52 +262 +245 +200 +171 +313 +306 +280 +27 +204 +101 +185 +37 +74 +298 +48 +169 +322 +35 +298 +183 +219 +423 +148 +152 +260 +326 +42 +330 +282 +163 +76 +137 +96 +244 +237 +442 +193 +434 +146 +185 +62 +424 +161 +228 +23 +93 +6 +189 +171 +82 +15 +315 +131 +73 +226 +269 +297 +315 +303 +317 +418 +455 +298 +404 +333 +29 +322 +57 +447 +407 +167 +286 +233 +230 +51 +112 +297 +264 +103 +482 +413 +117 +402 +153 +356 +44 +90 +443 +417 +273 +367 +413 +148 +115 +274 +336 +342 +309 +459 +242 +347 +461 +251 +103 +15 +134 +69 +217 +110 +43 +503 +120 +360 +361 +81 +97 +510 +433 +236 +492 +397 +130 +457 +206 +405 +446 +414 +429 +394 +485 +299 +366 +248 +351 +9 +406 +240 +237 +473 +457 +454 +512 +516 +90 +219 +334 +297 +9 +66 +466 +442 +536 +508 +277 +108 +150 +243 +496 +350 +513 +331 +190 +195 +232 +362 +226 +479 +345 +396 +161 +193 +33 +261 +314 +163 +475 +349 +172 +559 +225 +471 +475 +558 +208 +357 +486 +406 +59 +518 +285 +158 +179 +142 +48 +433 +494 +371 +244 +593 +364 +310 +164 +591 +165 +430 +98 +304 +67 +358 +445 +527 +293 +9 +577 +78 +246 +209 +613 +378 +592 +72 +527 +196 +92 +401 +362 +14 +573 +33 +422 +611 +255 +206 +215 +574 +372 +590 +383 +209 +635 +12 +193 +288 +65 +383 +581 +439 +118 +234 +466 +386 +576 +404 +373 +626 +566 +275 +641 +24 +230 +584 +175 +56 +366 +62 +274 +312 +475 +121 +72 +51 +29 +209 +86 +500 +109 +550 +98 +126 +469 +330 +662 +163 +498 +148 +188 +512 +62 +180 +103 +38 +1 +152 +632 +483 +690 +217 +9 +135 +255 +362 +332 +695 +542 +14 +708 +601 +459 +517 +159 +216 +216 +187 +549 +14 +500 +103 +194 +475 +510 +161 +185 +417 +88 +456 +418 +294 +482 +419 +117 +78 +460 +61 +602 +4 +470 +676 +345 +419 +357 +464 +736 +290 +312 +612 +607 +90 +412 +199 +629 +387 +561 +570 +370 +158 +384 +490 +744 +212 +302 +213 +290 +32 +720 +67 +164 +626 +178 +104 +582 +599 +269 +735 +553 +493 +266 +486 +126 +525 +708 +370 +98 +52 +688 +402 +323 +216 +775 +413 +736 +796 +38 +528 +228 +21 +131 +109 +632 +48 +510 +185 +189 +116 +758 +117 +228 +329 +667 +696 +182 +569 +66 +235 +428 +218 +332 +46 +479 +33 +751 +45 +460 +512 +494 +713 +27 +510 +536 +774 +389 +256 +468 +696 +567 +375 +683 +193 +713 +447 +199 +258 +256 +178 +775 +156 +829 +90 +244 +638 +751 +9 +765 +371 +428 +697 +360 +635 +207 +677 +255 +594 +182 +481 +787 +447 +278 +840 +731 +687 +812 +819 +385 +303 +466 +543 +111 +733 +619 +374 +157 +631 +370 +366 +818 +3 +318 +102 +686 +792 +882 +828 +812 +297 +333 +615 +705 +851 +876 +23 +338 +285 +733 +192 +645 +575 +797 +803 +621 +836 +914 +493 +605 +377 +609 +736 +344 +873 +806 +93 +782 +141 +771 +402 +331 +148 +73 +690 +717 +864 +483 +782 +592 +839 +183 +382 +247 +503 +526 +635 +731 +138 +190 +532 +446 +242 +846 +925 +944 +229 +460 +479 +603 +60 +39 +333 +697 +869 +174 +47 +736 +706 +801 +900 +426 +331 +630 +192 +840 +354 +37 +394 +314 +13 +105 +299 +937 +783 +394 +820 +763 +369 +938 +811 +122 +817 +470 +393 +395 +83 +104 +787 +663 +959 +897 +650 +404 +540 +79 +19 +506 +528 +622 +784 +495 +526 +234 +428 +377 +549 +15 +829 +886 +215 +763 +686 +361 +774 +689 +27 +788 +968 +89 +971 +261 +6 +661 +7 +179 +356 +798 +1005 +602 +446 +947 +515 +309 +650 +704 +996 +506 +361 +467 +40 +297 +934 +401 +859 +900 +700 +64 +965 +779 +570 +340 +122 +419 +1007 +1005 +1031 +491 +513 +90 +681 +148 +622 +560 +840 +389 +548 +106 +230 +456 +91 +594 +812 +474 +1015 +184 +304 +166 +661 +658 +416 +310 +666 +451 +946 +1043 +412 +902 +293 +637 +130 +671 +609 +1043 +1053 +361 +118 +317 +820 +737 +247 +119 +12 +605 +978 +262 +707 +669 +70 +489 +733 +523 +1064 +327 +452 +1005 +201 +758 +1091 +1105 +1126 +461 +512 +973 +986 +142 +251 +36 +632 +556 +923 +532 +997 +1042 +634 +562 +804 +460 +1052 +229 +880 +220 +362 +647 +135 +913 +111 +890 +55 +753 +113 +74 +464 +708 +438 +317 +478 +16 +1042 +908 +245 +109 +654 +460 +69 +918 +282 +399 +638 +749 +1116 +95 +59 +230 +694 +913 +1149 +321 +367 +155 +630 +1096 +429 +83 +233 +134 +139 +47 +530 +922 +504 +361 +1185 +717 +135 +562 +204 +1167 +271 +572 +966 +84 +1121 +1053 +571 +589 +1165 +611 +86 +26 +317 +431 +103 +779 +550 +477 +932 +824 +80 +1037 +226 +996 +289 +991 +820 +945 +965 +96 +332 +262 +1208 +151 +513 +140 +595 +485 +1007 +323 +362 +278 +644 +656 +507 +207 +29 +105 +1216 +830 +1024 +89 +1080 +1135 +507 +1063 +1240 +1222 +584 +454 +312 +1170 +465 +254 +656 +1229 +574 +1247 +911 +939 +1081 +579 +27 +1254 +838 +296 +151 +856 +1183 +823 +1058 +445 +994 +799 +1291 +1154 +25 +442 +47 +460 +947 +1194 +668 +315 +717 +427 +125 +277 +105 +1219 +104 +442 +761 +657 +954 +883 +350 +264 +1024 +972 +1052 +666 +704 +1177 +88 +1306 +715 +800 +672 +586 +692 +559 +602 +474 +15 +548 +833 +869 +629 +1138 +157 +202 +147 +114 +303 +449 +483 +1276 +104 +648 +470 +115 +640 +661 +67 +1199 +437 +1075 +233 +735 +456 +428 +361 +1254 +463 +423 +1234 +318 +300 +422 +1260 +1210 +1139 +581 +267 +1096 +385 +1204 +340 +1255 +341 +1072 +403 +670 +592 +322 +958 +1052 +1222 +744 +941 +4 +292 +1367 +533 +466 +257 +396 +39 +445 +1024 +449 +659 +145 +466 +536 +648 +1288 +49 +196 +337 +318 +973 +799 +783 +471 +392 +714 +872 +1202 +703 +271 +807 +493 +1125 +369 +603 +106 +1412 +954 +1103 +149 +685 +383 +443 +661 +947 +1413 +434 +1290 +556 +1047 +220 +1106 +979 +613 +1168 +537 +11 +438 +12 +984 +247 +191 +1437 +1376 +1094 +830 +1345 +1094 +993 +489 +283 +745 +744 +460 +567 +432 +1148 +727 +99 +1200 +725 +276 +989 +1392 +977 +860 +1150 +451 +1451 +1221 +1280 +1436 +627 +1405 +942 +113 +237 +444 +365 +1340 +610 +717 +1491 +1254 +503 +217 +1430 +254 +1309 +74 +416 +1160 +466 +401 +648 +1056 +603 +377 +935 +1085 +1475 +1384 +1115 +971 +465 +1195 +1172 +595 +1440 +913 +252 +597 +1420 +1227 +353 +426 +979 +689 +559 +1347 +356 +337 +362 +146 +976 +1028 +74 +1172 +173 +539 +685 +69 +1081 +1068 +641 +895 +1366 +430 +183 +231 +541 +985 +637 +358 +264 +466 +441 +1274 +711 +971 +1332 +391 +805 +729 +861 +681 +1279 +1377 +572 +227 +635 +726 +178 +1191 +1403 +779 +650 +257 +835 +294 +820 +190 +439 +836 +426 +302 +271 +42 +1000 +1090 +40 +1152 +617 +341 +938 +256 +420 +526 +928 +1242 +261 +467 +227 +1509 +1377 +411 +315 +363 +970 +861 +1457 +493 +336 +771 +21 +1240 +1113 +755 +926 +1424 +609 +518 +1553 +1134 +561 +284 +620 +347 +571 +805 +268 +135 +950 +409 +930 +742 +562 +315 +373 +182 +716 +842 +626 +193 +257 +1135 +1398 +836 +1345 +1201 +12 +1592 +936 +961 +485 +290 +763 +996 +1630 +417 +745 +286 +795 +140 +1660 +443 +252 +1203 +992 +694 +1585 +1518 +1140 +698 +1649 +131 +1054 +643 +1602 +1142 +1640 +1614 +397 +694 +1394 +916 +1521 +465 +1118 +1242 +623 +927 +1421 +1217 +175 +619 +185 +1519 +1604 +1091 +1263 +727 +662 +531 +1581 +1388 +1441 +1492 +1048 +210 +619 +97 +903 +747 +1633 +716 +857 +1331 +843 +294 +690 +1438 +893 +1138 +284 +849 +279 +997 +580 +1347 +1056 +1118 +1381 +108 +541 +1570 +251 +776 +861 +798 +1232 +1651 +1100 +1559 +1512 +1491 +1013 +1528 +1703 +872 +1693 +1623 +1293 +1545 +465 +1573 +442 +1474 +226 +117 +1287 +1495 +1015 +1185 +1574 +1375 +677 +584 +444 +815 +253 +1604 +1071 +1179 +770 +257 +1769 +970 +1509 +443 +1272 +1676 +198 +1663 +1253 +680 +619 +758 +686 +1669 +156 +24 +1077 +338 +263 +1436 +1118 +811 +959 +265 +973 +1790 +1718 +1424 +1708 +1605 +603 +312 +584 +920 +1330 +1686 +1362 +388 +260 +537 +299 +595 +925 +815 +922 +289 +1106 +3 +895 +1344 +1148 +1067 +302 +47 +1408 +864 +980 +1226 +782 +1815 +496 +323 +1305 +1680 +739 +411 +69 +873 +937 +1759 +1141 +739 +523 +174 +471 +158 +597 +247 +1805 +756 +177 +904 +1405 +1111 +1214 +1355 +1162 +111 +689 +1363 +246 +877 +760 +1328 +471 +454 +1529 +311 +857 +1408 +1513 +614 +186 +429 +332 +1189 +843 +1469 +133 +746 +372 +1016 +252 +731 +296 +745 +1129 +414 +1603 +1004 +1159 +1063 +155 +709 +1373 +864 +1747 +130 +42 +1045 +371 +330 +607 +814 +1106 +410 +836 +1043 +473 +1796 +1318 +1621 +1760 +422 +138 +497 +1140 +1454 +1865 +818 +1750 +330 +384 +1742 +1571 +1044 +997 +1278 +361 +332 +683 +221 +1870 +1673 +1183 +618 +1567 +119 +431 +1271 +745 +1316 +547 +1849 +619 +1112 +343 +229 +1056 +1949 +1666 +1742 +436 +540 +782 +1868 +614 +910 +597 +662 +950 +814 +1714 +33 +1021 +1524 +574 +1449 +1760 +1890 +1059 +82 +1686 +1762 +1507 +1475 +1299 +439 +1104 +1061 +410 +916 +1274 +273 +1154 +700 +1964 +794 +397 +201 +1312 +477 +414 +1580 +894 +344 +162 +1087 +717 +338 +798 +709 +657 +582 +267 +3 +811 +34 +1482 +1600 +1667 +76 +1241 +984 +1182 +93 +1752 +1409 +848 +792 +1912 +1671 +1567 +943 +1231 +1986 +1993 +878 +688 +455 +739 +884 +1398 +1843 +1642 +1850 +1402 +1943 +1170 +369 +1980 +413 +1859 +1957 +454 +516 +857 +341 +1333 +983 +2030 +1529 +1934 +341 +118 +193 +9 +1623 +1525 +1882 +1923 +477 +957 +1786 +232 +1574 +1608 +1778 +1132 +1322 +551 +402 +1035 +1835 +188 +960 +1004 +1917 +1090 +317 +673 +1373 +1735 +1699 +1302 +108 +272 +187 +166 +1062 +12 +1693 +1658 +1714 +2056 +277 +1834 +1702 +1868 +64 +263 +1878 +340 +1192 +298 +1703 +336 +543 +1130 +1291 +1858 +1065 +770 +553 +1841 +598 +632 +1375 +302 +2089 +525 +521 +1953 +1631 +700 +83 +1198 +13 +215 +332 +2057 +629 +1719 +1734 +2059 +1858 +1601 +269 +2078 +161 +732 +640 +97 +1920 +326 +971 +319 +2143 +443 +1845 +250 +257 +565 +606 +279 +1973 +832 +1986 +458 +441 +1866 +534 +548 +427 +925 +1707 +1486 +1142 +907 +1548 +1738 +1553 +410 +1107 +1779 +633 +476 +983 +1058 +939 +981 +231 +1717 +967 +807 +1749 +1954 +1175 +322 +1292 +1722 +36 +1304 +1062 +1276 +1555 +1238 +1826 +457 +1787 +198 +401 +847 +1238 +707 +1046 +1832 +273 +216 +736 +902 +775 +972 +1426 +1505 +1871 +1657 +260 +1127 +1669 +211 +812 +1 +321 +978 +167 +939 +363 +147 +2179 +657 +1308 +30 +106 +51 +395 +246 +892 +714 +962 +1223 +475 +758 +1519 +437 +1605 +1859 +426 +325 +1782 +841 +726 +2216 +1958 +921 +2109 +1585 +175 +2092 +1485 +1798 +1272 +256 +64 +2103 +68 +1080 +341 +1974 +1451 +460 +882 +2187 +2122 +1328 +2203 +256 +1920 +1382 +1632 +490 +2043 +124 +119 +1726 +1872 +2229 +233 +1353 +127 +1253 +162 +1090 +1185 +1522 +2070 +610 +203 +1771 +2066 +2283 +295 +2192 +828 +2254 +1096 +1735 +693 +1785 +70 +2016 +1217 +1658 +1192 +2142 +621 +2030 +2114 +1462 +793 +2052 +1502 +1177 +1717 +1688 +1799 +1259 +1769 +12 +1758 +2140 +1453 +220 +613 +125 +1463 +1888 +1377 +1698 +990 +1505 +1483 +2313 +567 +1673 +1023 +1963 +261 +1065 +990 +1568 +1768 +1031 +298 +1757 +557 +1861 +374 +133 +1228 +1424 +1143 +1343 +1770 +199 +110 +201 +680 +1859 +1549 +998 +1245 +2074 +1340 +1885 +1390 +1450 +923 +62 +1604 +1261 +877 +2261 +1144 +910 +1409 +2072 +1998 +286 +108 +1034 +792 +2042 +577 +463 +1730 +2146 +508 +1496 +554 +1669 +2095 +1700 +786 +493 +503 +234 +939 +473 +625 +1228 +514 +863 +1372 +1514 +1366 +2150 +2141 +288 +40 +2377 +1248 +1165 +438 +483 +2172 +417 +784 +1639 +1613 +475 +1520 +1929 +2349 +1686 +827 +1195 +1708 +2136 +1313 +1901 +1654 +872 +926 +1904 +251 +1485 +201 +628 +2062 +1500 +1642 +1445 +1473 +641 +788 +142 +1854 +405 +2238 +1336 +1442 +1757 +1031 +2184 +1943 +456 +2111 +411 +2473 +2209 +842 +85 +1072 +842 +840 +1365 +1241 +363 +1933 +1083 +301 +1844 +961 +2383 +2180 +1899 +151 +1512 +1585 +16 +1819 +1052 +2193 +1521 +695 +932 +2445 +432 +541 +1112 +2393 +1877 +433 +1084 +2344 +2022 +1568 +204 +2323 +110 +738 +975 +63 +2370 +20 +1794 +637 +1909 +973 +2111 +1054 +2273 +2140 +992 +936 +1433 +1636 +673 +155 +201 +34 +1250 +2405 +256 +834 +1100 +354 +1629 +847 +402 +166 +2047 +1578 +154 +813 +1991 +1648 +534 +504 +706 +1024 +2529 +1104 +2231 +1407 +2389 +183 +2047 +1781 +2119 +1361 +807 +1409 +1734 +139 +1645 +2101 +565 +2204 +91 +301 +11 +1169 +1037 +1166 +170 +2526 +743 +1315 +404 +1467 +153 +1958 +615 +1382 +2440 +196 +2170 +189 +139 +1422 +1994 +1926 +1678 +1203 +182 +2334 +407 +987 +2574 +2298 +921 +994 +519 +1930 +1959 +232 +1522 +1549 +2460 +768 +525 +2280 +884 +1164 +581 +344 +1497 +2244 +1571 +1022 +977 +1162 +1224 +616 +2042 +2498 +1322 +2452 +2449 +2180 +1344 +117 +1803 +1769 +1302 +2452 +583 +1962 +1986 +1407 +1009 +1637 +1282 +2590 +76 +2412 +2078 +2076 +2651 +2593 +1056 +2200 +1761 +594 +2267 +1183 +1395 +2371 +1346 +59 +1040 +2195 +2606 +643 +1048 +26 +1191 +891 +42 +1917 +2056 +1951 +295 +2622 +434 +121 +1271 +489 +11 +1389 +1497 +908 +827 +716 +107 +152 +2598 +2163 +1492 +2565 +1620 +1507 +552 +1968 +936 +802 +118 +800 +2665 +1110 +296 +1453 +339 +2179 +419 +862 +524 +1134 +2335 +1336 +2371 +1463 +1631 +563 +891 +361 +1041 +1210 +938 +1120 +644 +196 +584 +839 +1430 +884 +1089 +78 +1624 +293 +449 +636 +247 +1152 +1920 +488 +2561 +713 +1238 +1733 +826 +630 +1140 +1266 +1283 +2304 +1558 +612 +1011 +953 +1267 +111 +1926 +2577 +2110 +893 +449 +953 +1668 +1865 +1044 +2650 +773 +1819 +85 +182 +472 +1489 +2696 +2637 +1950 +1566 +2240 +572 +480 +2570 +1062 +523 +2085 +1899 +2760 +2425 +325 +2495 +332 +324 +2212 +2121 +1024 +1587 +341 +2243 +2758 +2206 +611 +2690 +339 +983 +2179 +482 +2717 +2373 +1460 +774 +2005 +187 +1153 +1559 +2573 +1628 +72 +2707 +729 +511 +509 +720 +317 +2640 +1186 +2527 +620 +675 +503 +310 +2061 +1897 +2043 +94 +18 +1873 +2343 +2794 +278 +2472 +37 +1132 +1041 +551 +1333 +1694 +836 +284 +881 +1110 +850 +976 +75 +827 +2397 +182 +1313 +2835 +1283 +2325 +759 +1464 +7 +2306 +2404 +2523 +2396 +2677 +2366 +2847 +1875 +2737 +1453 +2646 +1518 +135 +1857 +2555 +834 +2476 +1228 +1728 +2344 +2740 +2351 +2714 +239 +1970 +1806 +350 +1238 +1032 +94 +2370 +2564 +1029 +668 +2360 +561 +2145 +2761 +2889 +1151 +646 +2881 +425 +2408 +1909 +729 +1940 +2364 +1162 +2071 +1662 +1233 +1221 +2181 +1333 +1079 +430 +168 +973 +506 +1349 +2274 +1054 +1486 +2121 +2609 +983 +1933 +1137 +1997 +604 +1445 +2149 +163 +1741 +2305 +150 +2224 +2511 +670 +146 +2832 +2174 +578 +1327 +29 +2502 +2734 +88 +2841 +1270 +2504 +1908 +623 +2636 +708 +2138 +1696 +1015 +1543 +550 +2547 +1965 +1063 +2023 +2299 +2157 +2420 +1016 +2873 +2448 +1944 +2623 +788 +2617 +1423 +535 +192 +21 +327 +2598 +1402 +940 +13 +2053 +848 +1260 +1501 +2646 +756 +2534 +586 +2683 +23 +2601 +652 +1613 +1139 +2201 +177 +174 +2291 +279 +2218 +1934 +3009 +1349 +2250 +746 +21 +684 +51 +1828 +2981 +862 +2974 +1194 +1944 +2124 +1762 +1152 +1709 +1899 +2820 +2995 +965 +2854 +1900 +489 +84 +500 +2714 +640 +207 +1975 +627 +1689 +1666 +1366 +2409 +1727 +2524 +1848 +541 +1392 +1093 +1828 +37 +1991 +2801 +1729 +1733 +987 +364 +636 +70 +1960 +426 +1196 +96 +2630 +2615 +2171 +2826 +1923 +2977 +2751 +2249 +2360 +1762 +2944 +1886 +2403 +771 +1511 +1516 +649 +2537 +413 +2262 +595 +1300 +186 +2282 +1187 +1523 +1418 +1398 +1323 +842 +146 +594 +744 +1786 +840 +2470 +134 +1902 +1441 +1390 +435 +2002 +835 +2674 +1938 +2872 +3046 +743 +2368 +412 +1924 +3030 +1582 +1719 +299 +1870 +2953 +2382 +2800 +2999 +2516 +629 +1736 +475 +1026 +1018 +1155 +1823 +2547 +1722 +2905 +638 +470 +2957 +1392 +1781 +510 +363 +1525 +1448 +948 +676 +1260 +199 +543 +3015 +3109 +1699 +1151 +367 +666 +711 +830 +2567 +2363 +2492 +1574 +368 +605 +661 +1763 +1290 +70 +378 +3026 +291 +132 +929 +455 +2561 +733 +2996 +2045 +1018 +1229 +2742 +1454 +727 +1884 +2813 +789 +442 +2254 +1526 +2401 +2508 +2491 +1383 +1608 +1301 +1466 +1897 +1562 +2666 +1575 +1943 +3188 +608 +992 +1562 +1089 +2356 +767 +369 +1753 +1019 +1110 +2558 +2682 +630 +2109 +297 +2985 +2201 +1997 +1659 +2588 +349 +70 +1742 +2573 +55 +3119 +198 +118 +2995 +774 +504 +1153 +630 +2142 +2808 +2352 +2939 +2242 +1783 +2242 +2540 +1099 +2064 +1553 +505 +444 +3010 +1708 +101 +248 +3229 +3176 +4 +2386 +53 +442 +2489 +1310 +1683 +1168 +1245 +384 +1227 +382 +744 +2061 +728 +354 +3040 +954 +1947 +3108 +1088 +2509 +1858 +736 +2640 +2943 +86 +3097 +3127 +844 +2663 +2779 +1739 +2055 +1590 +1024 +3090 +2852 +3207 +1133 +2017 +3072 +546 +235 +1537 +1416 +2239 +1736 +1955 +1865 +727 +2065 +3159 +2489 +356 +2384 +2601 +1389 +1104 +1378 +2576 +1175 +1493 +2099 +2909 +2507 +3070 +1969 +1767 +2901 +2492 +852 +2343 +2172 +2030 +708 +675 +996 +585 +3152 +1486 +3301 +1083 +850 +1667 +196 +484 +19 +1366 +648 +1234 +2692 +1829 +416 +378 +1980 +3274 +2167 +2093 +1517 +1888 +3162 +739 +412 +2480 +2693 +837 +1122 +1953 +316 +490 +2144 +2012 +283 +1072 +3193 +32 +1847 +1186 +2464 +1157 +3278 +1590 +2943 +2474 +1320 +354 +3302 +1683 +1320 +421 +698 +2603 +2848 +2574 +1246 +2262 +2671 +1903 +953 +781 +485 +813 +1233 +3357 +2022 +2763 +2238 +2422 +3372 +2103 +892 +230 +1969 +2222 +2139 +2771 +2649 +216 +2161 +466 +1681 +2265 +1437 +2105 +918 +2018 +2434 +2260 +2903 +174 +1452 +872 +1584 +858 +1680 +2324 +2507 +1648 +675 +2075 +1913 +614 +2532 +1993 +3162 +1335 +814 +2880 +59 +1011 +2256 +628 +3311 +2332 +823 +2268 +548 +2400 +1879 +2084 +2063 +3344 +3377 +2381 +619 +1473 +3458 +2347 +3374 +1875 +2508 +2317 +1578 +2409 +552 +472 +2530 +893 +116 +697 +3133 +3186 +549 +29 +1755 +1075 +3393 +148 +812 +1501 +2471 +2426 +2586 +2591 +3287 +1637 +1942 +2575 +1746 +1065 +1789 +2417 +2381 +1494 +141 +3164 +1835 +2326 diff --git a/solutions/beecrowd/1032/problem.md b/solutions/beecrowd/1032/problem.md new file mode 100644 index 00000000..5a9e4459 --- /dev/null +++ b/solutions/beecrowd/1032/problem.md @@ -0,0 +1,35 @@ +https://judge.beecrowd.com/en/problems/view/1032 + +# Joseph’s Cousin + +The Joseph’s problem is notoriously known. For those who are not familiar with +the problem, among people numbered 1,2…n, standing in circle every mth is going +to be executed and only the life of the last remaining person will be saved. +Joseph was smart enough to choose the position of the last remaining person, +thus saving his life to give the message about the incident. + +Although many good programmers have been saved since Joseph spread out this +information, Joseph’s cousin introduced a new variant of the malignant game. +This insane character is known for its barbarian ideas and wishes to clean up +the world from silly programmers. We had to infiltrate some agents of the ACM in +order to know the process in this new mortal game. + +In order to save yourself from this evil practice, you must develop a tool +capable of predicting which person will be saved. + +The Destructive Process + +The persons are eliminated in a very peculiar order; m is a dynamical variable, +which each time takes a different value corresponding to the prime numbers’ +succession (2,3,5,7…). So in order to kill the ith person, Joseph’s cousin +counts up to the ith prime. + +## Input + +It consists of separated lines containing n [1..3501], and finishes with a 0. + +## Output + +The output will consist in separated lines containing the person's position +which the life will be saved. + diff --git a/solutions/beecrowd/1032/tags.txt b/solutions/beecrowd/1032/tags.txt new file mode 100644 index 00000000..07915351 --- /dev/null +++ b/solutions/beecrowd/1032/tags.txt @@ -0,0 +1 @@ +ad-hoc, josephus problem