Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Good problem (there is hint inside) | medegor44 💭💡🎈 | 1755. Cake | 6 Mar 2019 15:44 | 1 | Easy to solve with linear programming | | My Solution is here | vetas | 1407. One-two, One-two | 6 Mar 2019 15:44 | 4 | ## Russian ## ## 1 Идея ## 1) Представим число A в виде 10x+m1, где x - число десятков m1=2 (m1 не может быть равно 1, так как в этом случае искомое число A нечетное и на 2^N не разделится). Разделим число на 2, получим A=5x+1. 2) Пусть x=10y+m2, где y - число сотен. После подстановки получим A=5(10y+m2)+1=50y+5m2+1. Чтобы число A разделилось на 2, надо, чтобы m2 было нечетным. Следовательно выбираем m2=1. После деления на 2 получим: A=(50y+5*1+1)/2=25y+3. 3) Пусть y=10z+m3, где z - число тысяч. После подстановки получим A=25(10z+m3)+3=250z+25m3+3. Чтобы число A разделилось на 2, надо, чтобы m3 было нечетным. Следовательно выбираем m3=1. После деления на 2 получим: A=(250z+25*1+3)/2=125z+14. 4) Пусть z=10t+m4, где t - число десятков тысяч. После подстановки получим A=125(10t+m4)+14=1250t+125m4+14. Чтобы число A разделилось на 2, надо, чтобы m4 было четным. Следовательно выбираем m4=2. После деления на 2 получим: A=(1250t+125*2+14)/2=625t+132. Далее процесс повторяется N раз. Последовательность mN...m4m3m2m1 образует ответ. Алгоритм требует применения длинной арифметики. Общее решение достигается за N шагов. ## 2 Алгоритм ## Пусть m[1]=2; a_[1]=5; b_[1]=1; Цикл i = от 2 до n нц m_[i]=(если b_[i-1] нечетное, то 1, иначе 2) b_[i]=(если b_[i-1] нечетное, то (a_[i-1]+b_[i-1])/2, иначе (2*a_[i-1]+b_[i-1])/2) (так как a_[i-1] нечетное всегда по определению) a_[i]=a_[i-1]*5; кц ## English (in short) ## ## 1 The Idea ## 1) Let me A = 10x+m1, where x - number of Tens m1=2 (m1<>1, as A - odd). Division A in 2, let's receive A=5x+1. 2) Let me x=10y+m2, where y - number of Hundreds. Then A=5(10y+m2)+1=50y+5m2+1. if A%2==0, m2 is odd. Then m2=1 and A=(50y+5*1+1)/2=25y+3. 3) Let me y=10z+m3, where z - number of Thousand. Then A=25(10z+m3)+3=250z+25m3+3. if A%2==0, m3 is odd. Then m3=1 and A=(250z+25*1+3)/2=125z+14. 4) Let me z=10t+m4, где t - number of Tens thousand. Then A=125(10t+m4)+14=1250t+125m4+14. if A%2==0, m3 is even. Then m3=1 and A=(1250t+125*2+14)/2=625t+132. Further process repeats N time. Sequence mN... m4m3m2m1 forms the answer. The algorithm demands application of long arithmetics. ## 2 The Algo ## Let me m[1]=2; a_[1]=5; b_[1]=1; for i = 2 to n begin m_[i]=(if b_[i-1] is odd, then 1, else 2) b_[i]=(if b_[i-1] is odd, then (a_[i-1]+b_[i-1])/2, else (2*a_[i-1]+b_[i-1])/2) a_[i]=a_[i-1]*5; end thank you! excellent idea! Можно проще. Индукция: для любого n существует число x(n) из 1 и 2 длиной n, делящееся на 2^n. База: n=1=>x(1)=2. Переход n->n+1: если x(n) делится на 2^(n+1), то в качестве x(n+1) можно взять x(n+1)=2x(n) (т.е. слева приписать 2), иначе x(n+1)=1x(n). Edited by author 10.03.2019 13:22 | | help test 8 | Arsen Babakhanyan | 1931. Excellent Team | 4 Mar 2019 12:31 | 5 | whats in test 8 ? cant find out :( try to use this one 5 2 3 0 4 5 Hint: when the pirate becomes the current best option, he is also being compared. Thus in the test case above pirate 1 will be compared 2 times, while pirate 3 will be compared 3! GL!!! Try this test 6 2 2 2 1 1 1 ans: 4 | | What is wrong here?С# | Константин | 1428. Jedi Riddle | 3 Mar 2019 17:44 | 1 | using System; class Entrypiont { static void Main() { string[] Input = Console.ReadLine().Split(' '); int a = Convert.ToInt32(Input[0]); int b = Convert.ToInt32(Input[1]); int c = Convert.ToInt32(Input[2]); if(((c-1)%a)==((c-1)%b) && ((c - 1) % a) == 0) { int x=1, y=1, z=1; while (true) { if(Math.Pow(x,a)+ Math.Pow(y, b)== Math.Pow(z, c)) { Console.Write(x); Console.Write(y); Console.Write(z); break; } else { if(Math.Pow(x, a) + Math.Pow(y, b) >Math.Pow(z, c)) { z++; } else { if (x >= y) { y++; } else { x++; }
} } } } Console.ReadLine(); } } | | WA2 | Михаил | 1855. Trade Guilds of Erathia | 3 Mar 2019 00:15 | 1 | WA2 Михаил 3 Mar 2019 00:15 | | For those who have WA #17 | RPTREME | 1297. Palindrome | 2 Mar 2019 22:19 | 3 | It's not that test( I have WA#17 but my prog writes "BB" on this test I had WA on this test. I used manacher algorithm from e-maxx, in realization on site is one mistake, what ruin solution on this test, after correcting i got AC | | Acceepted | Viktor Krivoshchekov`~ | 1348. Goat in the Garden 2 | 2 Mar 2019 19:20 | 1 | Acceepted Viktor Krivoshchekov`~ 2 Mar 2019 19:20 #include <iostream> #include <cmath> #include <vector> #include <algorithm> #include <string> #include <iomanip> #include <set> using namespace std; int main() { int x1, x2, y1, y2, x3, y3, l; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> l; // h = 2/s3 в€љp(p-s3)(p-s1)(p-s2), int a = y1 - y2, b = x2 - x1, c = x1 * y2 - x2 * y1; double s1 = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)), s2 = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3)), s3 = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); double p = s1 + s2 + s3; p /= 2; double ans = (2 / s3 * sqrt(p * (p - s3) * (p - s1) * (p - s2))); if (max(s1, s2) * max(s1, s2) > min(s1, s2) * min(s1, s2) + s3 * s3) { ans = min(sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)), sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3))); } if (s3 == 0.0) { ans = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) *(y1 - y3)); } printf("%0.2f\n", max(0.0, ans - l)); printf("%0.2f\n", max(0.0, max(sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)), sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3))) - l)); } | | Why ans is not 2? | Rustam_SBOne | 1104. Don’t Ask Woman about Her Age | 2 Mar 2019 18:30 | 2 | k=2 => k-1 = 1. But everything is divisible by 1, what's wrong? Not all numbers could be written in binary number system | | easy solution in c++ | Yucheng | 1084. Goat in the Garden | 2 Mar 2019 14:50 | 1 | #include<iostream> #include<cmath> #include<iomanip> #define pi 3.1415926 using namespace std; int main(){ float side,len; cin>>side>>len; if(len>(side/2)*sqrt(2)){ cout<<fixed<<setprecision(3)<<side*side; return 0; } if((side/2)>=len){ cout<<fixed<<setprecision(3)<<len*len*pi; return 0; } float cosx=(side/2)/len; float sinx=sqrt(1-cosx*cosx); float cosA=2*sinx*cosx; float theta=acos(cosA); cout<<fixed<<setprecision(3)<<len*len*0.5*theta*4+sqrt(len*len-(side/2)*(side/2))*(side/2)*4;
return 0; } | | SIRIUS | Anti Sirius | 2025. Line Fighting | 1 Mar 2019 21:45 | 4 | SIRIUS Anti Sirius 25 Oct 2014 16:34 Re: SIRIUS Nodir NAZAROV [TUIT-Karshi] 8 Dec 2014 19:14 Re: SIRIUS egardoz[Yaroslavl SU]🔥☭ 1 Mar 2019 21:45 nima uchun o'zbek tilida gapirasiz? | | GOOD peoples Please help me :( | N0D1R | 1671. Anansi's Cobweb | 28 Feb 2019 16:14 | 6 | GOOD peoples Please help me! I have got WA#5! I used DSU!! My program gives right answer for all my tests! But again WA#5 and I can not found my mistake! I shall wait advices or tests! Thank you advance!!! What test you used to check it? 4 4 1 2 1 2 2 3 3 4 3 1 2 3 good luck!!! | | Everybody who get confused on this problem should look at this!! | Dryad | 1067. Disk Tree | 28 Feb 2019 08:50 | 4 | just consider this condiction: 2 A\A B\A the correct output is A A B A but if you are mistaken, you will output A A Of course, folders on different depths (or in different subtrees) can have equal names. (look at disk tree on your computer). Edited by author 30.10.2004 22:38 Why couldn't it be : B A A ?? All the given directory addresses start from same common root | | TLE on #39 | Barish_Namazov | 2102. Michael and Cryptography | 27 Feb 2019 12:56 | 4 | Re: TLE on #39 George_Aloyan[PTS_Obninsk][MIPT][IPG][ALIGN][YANDEX] 27 Feb 2019 12:56 The least prime divider in tests is less than 1.1E6 (but checking till 8E7 will still got AC) | | My STRANGE but ACed algorithm | 198808xc | 1396. Maximum. Version 2 | 26 Feb 2019 21:39 | 2 | I think that most people trying to solve this problem will try to deal with two problems, they are: 1. How to calculate a[n] fast? 2. How to find those n that a[n] is the maximum in [1...n]? Here is my method. 1. Calculating a[n] (without calculating a[1...n-1]). Directly calculation will lead to a long time. But, after some observation, I found that: a[4n] = a[n] a[4n + 1] = a[2n] + a[2n + 1] = 2a[n] + a[n + 1] a[4n + 2] = a[n] + a[n + 1] a[4n + 3] = a[n] + 2a[n + 1] So, a[4n] to a[4n + 3] could be presented as the linear form of a[n] and a[n + 1]. We will soon realise that, a[2^k n] to a[2^k n + (2^k - 1)] could also be presented as linear form of a[n] and a[n + 1]. So, pre-calculation is done to calculate all the linear forms of a[65536n] to a[65536n + 65535]. This will take about O(65536 * 2) time. After this pre-calc, calculation for any number K will go very fast. 2. Finding the maximum. After listing some of the 'maximum index', we found that: 1 3 5 9 11 19 21 35 37 43 ...... Maybe my math is not so good, so I could not find so useful properties in the array, but I noticed one thing: ------------------------------------------------------------------------------------------ Every 'maximunm index' could be presented as its max 2-power and some former 'maximum index'. ------------------------------------------------------------------------------------------ Sorry for my poor English, let's take a look at the examples: 1 3 = 2 + 1 5 = 4 + 1 9 = 8 + 1 11 = 8 + 3 19 = 16 + 3 21 = 16 + 5 35 = 32 + 3 37 = 32 + 5 43 = 32 + 11 ...... So, we just need to use every 2^k number to ITERATE the list of 'maximum index'. As the list is of size O(Log N), the algo runs quite fast. With above methods, I got AC in 0.046 sec. Well, if my algo is too stupid for you, don't hesitate to post your algo here. Have fun and good luck. | | test#1. Why? | Igor | 1712. Cipher Grille | 26 Feb 2019 13:29 | 1 | #include <iostream> using namespace std; char paper[4][4], pass[4][4],rPass[16],TempPaper[4][4]; int v, i, j; void check(char paper[4][4], char pass[4][4]) { for (int j = 0; j < 4; j++)// X/. { for (int i = 0; i < 4; i++) { if (paper[j][i] == 'X') { rPass[v] = pass[j][i]; v++; } } } } int main() { for (int j = 0; j < 4; j++) //paper cin { for (int i = 0; i < 4; i++) { cin >> paper[j][i]; } } for (int j = 0; j < 4; j++)//зашифрованый пароль { for (int i = 0; i < 4; i++) { cin >> pass[j][i]; } } for (int j = 0; j < 4; j++)//temp { for (int i = 0; i < 4; i++) { TempPaper[j][i] = paper[j][i]; } } check(paper, pass); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { int t=0, y; if (j == 0) { int u = 3; for (y = 0; y < 4; y++) { paper[t][u] = TempPaper[0][y]; t++; } } if (j == 1) { int u = 2; for (y = 0; y < 4; y++) { paper[t][u] = TempPaper[1][y]; t++; } } if (j == 2) { int u = 1; for (y = 0; y < 4; y++) { paper[t][u] = TempPaper[2][y]; t++; } } if (j == 3) { int u = 0; for (y = 0; y < 4; y++) { paper[t][u] = TempPaper[3][y]; t++; } } } check(paper, pass); for (int j = 0; j < 4; j++) { for (int i = 0; i < 4; i++) { TempPaper[j][i] = paper[j][i]; } } } return 0; } | | Test 7 | Gilles Deleuze | 2107. Oppa Funcan Style | 25 Feb 2019 19:25 | 1 | Test 7 Gilles Deleuze 25 Feb 2019 19:25 It contains more than 20 zeroes. | | WA #30 | sergio74 | 1637. Triangle Game 2 | 25 Feb 2019 12:56 | 2 | WA #30 sergio74 21 Feb 2019 01:42 Totally discouraged with it. Please give some test. Got AC. There was an unobvious but very stupid bug... | | WA 23 .... wth is this. -_- | Ealham | 1494. Monobilliards | 24 Feb 2019 01:32 | 5 | I used a simple algo... I am just checking 3 consecutive numbers... If any 3 consecutive numbers from the given numbers are like this, n1>n3>n2 (mid one is the smallest, first one is the largest and the last one lies in between these two values) , then the sequence is invalid (Cheater) ... else , I print "Not a proof" ... Is my algo ok? If so, then please help me with some test cases... I have tried all the test cases found in the discussions and my program passed all of them... Thanks a lot for your answer. I haven't heard about "Process Modelling" ... I'll look into it asap. And my algo that I used is wrong actually. It fails in this type of cases... 4 3 1 4 2 Correct answer is "Cheater", but my program shows "Not a proof"... I wonder how it passed 22 tests... 0_O Thanks again... :) «I haven't heard about "Process Modelling" ... I'll look into it asap.» Well, it's simple. Basically you just put balls into array in a proper order, and when the last ball is a current takeout request, you take it out of the array and move to next takeout request, and repeat if needed. If at certain point the takeout ball is not the one you expect, the answer is cheater. Good luck~ | | why wa it's ok verious input | INFINITE | 2012. About Grisha N. | 23 Feb 2019 21:32 | 1 | #include<bits/stdc++.h> using namespace std; int main(void) { int t_h,s_h,pb; while(cin>>pb) { s_h=0,t_h=0; if(pb>=1 && pb<=11) { s_h=12-pb; t_h=s_h*45; if(t_h<=240) cout<<"Yes"<<endl; else cout<<"No"<<endl; } } return 0; } | | 5 test? c | Sanchir | 1243. Divorce of the Seven Dwarfs | 23 Feb 2019 17:10 | 1 | #include <stdio.h> int main() { unsigned long long int a; scanf("%llu", &a); if (a/7!=0) printf("%llu\n", a%7); else if (a < 7) printf("%d\n", a); } |
|
|