Common BoardShow all threads Hide all threads Show all messages Hide all messages | Idea | __Andrewy__ | 1615. Tram Solitaire | 12 Aug 2025 22:26 | 1 | Idea __Andrewy__ 12 Aug 2025 22:26 1) Посмотрим, как выглядят плохие расстановки. Тогда ответ = количество хороших расстановок / количество всех расстановок. Обозначим расстановки карт как x = x_1 x_2 ... x_2n. 2) Количество всех расстановок (2n)! 3) Как выглядят плохие расстановки, те когда пасьянс в конце будет содержать >=3 карт? Чтобы нельзя было сделать ход, нужно чтобы суффикс имел вид (1) ai * bj либо (2) bi * aj, где i != j, а * - любая карта. Заметим, что если какой-то суффикс x после всех просеиваний переходит в один из таких видов, то пасьянс не сойдётся. Можно доказать обратное: если никакой суффикс x при просеиваниях не перейдёт в (1) или (2), то пасьянс сойдется. 4) Из 3) можно построить все плохие расстановки. Они будут иметь вид: x_1 ... x_[2n-3] bj x_[2n-1] ai x_1 ... x_[2n-4] bj a_l1 a_l2 ai x_1 ... x_[2n-5] bj a_l1 a_l2 a_l3 ai x_1 ... x_[2n-5] bj a_l1 a_l2 a_l3 a_l4 ai ... Здесь bj, ai, a_l1, a_l2, ... - выбранные карты (j != i), x_k - оставшиеся карты. Аналогично к плохим расстановкам будут относится все с заменой местами bj и ai (вместо a_l1, a_l2, ... будут b_l1, b_l2, ...). Первых расстановок ровно 2n*(n-1)*(2n-2)! Вторых расстановок 2n*(n-1)*(n-1)*(n-2)*(2n-4)! = 2n*(n-1)*(n-1)! * (2n-4)! Третьих расстановок 2n*(n-1)*(n-1)*(n-2)*(n-3)*(2n-5)! = 2n*(n-1)*(n-1)! / 2! * (2n-5)! Четвертых расстановок 2n*(n-1)*(n-1)*(n-2)*(n-3)*(n-4)*(2n-6)! = 2n*(n-1)*(n-1)! / 3! * (2n-6)! И т.д. до n+1. Итого плохих расстановок bad_cnt = 2n*(n-1)*(2n-2)! + 2n*(n-1)*(n-1)! * sum((2n-k)!/(n-k+1)!), k=4,...,n+1 good_cnt = (2n)! - bad_cnt d = gcd(good_cnt, (2n)!) Ответ = (good_cnt / d, (2n)! / d) PS: надеюсь не опечатался Тесты: (2, '2/3') (3, '8/15') (4, '13/28') (5, '19/45') (6, '13/33') (7, '34/91') (8, '43/120') (9, '53/153') (10, '32/95') (11, '76/231') (12, '89/276') (13, '103/325') (14, '59/189') (15, '134/435') (16, '151/496') (17, '169/561') (18, '94/315') (19, '208/703') (69, '2483/9453') (100, '5149/19900') (666, '111388/443223') (1234, '381614/1522139') (10000, '50014999/199990000') (100000, '5000149999/19999900000') Edited by author 12.08.2025 22:29 | Wa 25-27 | Hououin`~`Kyouma | 1863. Peaceful Atom | 12 Aug 2025 17:06 | 1 | Wa 25-27 Hououin`~`Kyouma 12 Aug 2025 17:06 | suffix automaton | datym | 1713. Key Substrings | 11 Aug 2025 16:07 | 1 | | Hint for Tl | Hououin`~`Kyouma | 1844. Warlord of the Army of Mages | 11 Aug 2025 12:45 | 1 | Precalc + don't use set, use bitsets instead | Hint for WA 2 and 5, that helped me | Hououin`~`Kyouma | 1844. Warlord of the Army of Mages | 11 Aug 2025 12:41 | 1 | "You have to determine whether such a stupid DEFEAT is possible." NOT a victory, but a DEFEAT. Edited by author 11.08.2025 12:41 | WA 6 | ~'Yamca`~ | 1655. Somali Pirates | 10 Aug 2025 14:12 | 1 | WA 6 ~'Yamca`~ 10 Aug 2025 14:12 Problem with accuracy, you should print exactly 3 digit after dot | hint/spoiler | ~'Yamca`~ | 2196. Apocalypse | 9 Aug 2025 05:21 | 1 | You can use sqrt-decomposition to find nearest point. It much easier than tangent, but slowly | a little hint | ~'Yamca`~ | 1558. Periodical Numbers | 8 Aug 2025 11:53 | 1 | period + preperiod always < 100, so you can use bruteforce:) | Help.Need in tests | Felix_Mate | 1387. Vasya's Dad | 8 Aug 2025 11:26 | 2 | WA21; My tests: N=9 =>286 N=13 =>12486 N=20 =>12826228 N=25 =>1142161275355632 N=33 =>13654755591665021157 N=25 => 2067174645 N=33 => 7929819784355 | This test helped me | 0bla4ko`~ | 1202. Rectangles Travel | 7 Aug 2025 20:22 | 1 | 3 0 0 6 8 6 -3 11 6 11 -3 21 0 Answer 21 | WA Test 28 | Maxim Popkov | 1884. Way to the University | 7 Aug 2025 04:30 | 1 | Please, help!!! Tell me the test 28! | WA 2 | ~'Yamca`~ | 1323. Classmates | 5 Aug 2025 08:50 | 1 | WA 2 ~'Yamca`~ 5 Aug 2025 08:50 if you use dp + bimatching your matching algo is wrong | Beautiful accepted | Axmed | 1385. Interesting Number | 4 Aug 2025 16:26 | 1 | We have number n = a * (10 ^ n) + b. n mod a = 0 and n mod b = 0 If n mod a = 0 that b mod a = 0. If n mod b = 0 that a * (10 ^ n) mod b = 0 We have now b mod a = 0 a * (10 ^ n) mod b = 0 Ok, now let's imagine b = k * a. First condition is fulfilled. a * (10 ^ n) / (k * a) = 10 ^ n / k K is divider of 10 ^ n. Let's note that k is less then 10. Why? Because a * 10 have n + 1 digit but b must have n digit. Now for all 1 <= k <= 9 and 10^n mod k = 0 we calculate how many good numbers a we can use, a * k must have n digit that 10 ^ (n - 1) <= a <= (10 ^ n - 1) // k. Sum of all good ways to choose a and k is answer! | If you don't understand how the figures produces | andreyDagger`~ | 1442. Floo Powder | 4 Aug 2025 15:33 | 1 | Let l="line which connects top corner of cone and one of the points on the corner of base" Also a="angle between 'l' and surface" A line is drawn on the surface with distance d to the center of cone. Then two 2d planes are drawn through this line. The angle between plane and surface is equal to 'a'. These planes are directed in the opposite angles. Set of points that are in the cone and between these 2d planes will fall in the slit | Easy Accepted | Axmed | 1204. Idempotents | 4 Aug 2025 13:11 | 1 | At first N = p * q, let's find this prime numbers p and q. Now we have x * x = x mod N. x * x - x = 0 mod N x * (x - 1) = 0 mod N Let's note that x != pq, because x < n. That means x mod p = 0, x - 1 mod q = 0 or x mod q = 0, x - 1 mod p = 0. Consider { x mod p = 0 x mod q = 1 } another case is symmetrical. x = k * p, because x mod p = 0. Now we have k * p mod q = 1 k = 1 / p mod q k = p ^ (-1) mod q Use Fermat's little theorem k = p ^ (q - 2) mod q. We find x = k * p, problem is solved. | WA 4 | andreyDagger`~ | 1661. Dodecahedron | 4 Aug 2025 12:08 | 1 | WA 4 andreyDagger`~ 4 Aug 2025 12:08 Rotations with cycles of length 2 actually have two fixed points | Whats 28 WA | grmmmely | 1014. Product of Digits | 3 Aug 2025 20:52 | 1 | | wa12 | 👑TIMOFEY👑`~ | 1074. Very Short Problem | 1 Aug 2025 16:32 | 1 | wa12 👑TIMOFEY👑`~ 1 Aug 2025 16:32 maybe -0 0 -0 1 answer should be without -, i changed that and got ac | How come there are solutions that are 0.015 sec and less than 0.1 sec | Sergey | 2130. Alice + Bob | 31 Jul 2025 19:45 | 4 | my solution is the following: start with least common multiple = 1 make char array of 1000 000 to track forbidden divisors let div be the divisor and ans the answer if ans == 1 make new lcm of the previous lcm and current divisor. if it is over 10^12 - fail. find all the divisors of div, check that they are not forbidden in the forbidden array if ans == 0 - check if lcm is divisible by the divisor and fail if it is.
complexitiy O(n * sqrt(1000000)) (sqrt from the "find all divisors) my solution gets 0.5 sec (using cin,cout with tie(null)) what is the solution that gets less than 0.1 sec? Is there any hint? no need to find all divisors. u can just use lcm and mod operations. i can send you easy solution if u r still interested need to pray to god for quick solutions #pragma GCC optimize("Ofast") #pragma GCC optimize(O3) #pragma comment(linker, "/stack:200000000") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("profile-values,profile-reorder-functions,tracer") #pragma GCC optimize("vpt") #pragma GCC optimize("rename-registers") #pragma GCC optimize("move-loop-invariants") #pragma GCC optimize("unswitch-loops") #pragma GCC optimize("function-sections") #pragma GCC optimize("data-sections") #pragma GCC optimize("branch-target-load-optimize") #pragma GCC optimize("branch-target-load-optimize2") #pragma GCC optimize("btr-bb-exclusive") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("inline-small-functions") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fexpensive-optimizations") #pragma GCC optimize("inline-functions-called-once") #pragma GCC optimize("-fdelete-null-pointer-checks") | suffix automaton | datym | 1769. Old Ural Legend | 30 Jul 2025 20:33 | 1 | |
|
|