Common Board| Show all threads Hide all threads Show all messages Hide all messages | | В чем, собственно, условие, если нет логики? | Riot | 2001. Mathematicians and Berries | 20 Oct 2016 00:17 | 2 | В примере, в результате написано "1 1", однако в вычислениях мы видим "1 2 - 2 1 - 0 3". Откуда, спрашивается, взялась еще одна единица? Каждый собрал по 1 кг, при пересыпаниях туда-сюда получаем 0кг и 2кг и наоборот. Объясните нормально условие Baskets weight something. Weight isn't fixed, isn't the same and should be found to receive program solution. In the example first basket weights 0 kg (plastic packet?). Second basket weights 1 kg. Edited by author 20.10.2016 14:58 | | why for k=8, N=15. N=11 looks perfectly correct. | Vedsar Kushwaha | 1673. Admission to Exam | 19 Oct 2016 19:42 | 2 | If K=8, i.e 1,2,3,4,5,6,7,8 students. Now, each student has to sit for at least 1 lab of each professor. For N=11, Students 1 will sit in all labs, hence qualified for exam. Students 2 will sit in labs: 2,4,6,8,10,12,14,16,18,20,22. hence qualified for exam. (At least 1 lab of all Prof covered) Students 3 will sit in labs: 3,6,9,12,15,18,21,24,27,30,33 labs. hence qualified for exam. (At least 1 lab of all Prof covered) . . . Similarly Student 8 will sit in 8,16,.....,88 labs, hence qualified for exam. (At least 1 lab of all Prof covered) Please help, where I'm wrong. Just got it. N=11 will violate "exactly K students" condition. For N=11, there will be 10 students who can qualify for exams. | | If N = 0 Q = -1 or Q = 0? | Orventro | 1014. Product of Digits | 18 Oct 2016 21:30 | 2 | If N = 0 Q = -1 or Q = 0? | | WA4, C#, Please help to find a mistake | Michael | 1100. Final Standings | 18 Oct 2016 20:04 | 3 | I use LINQ to sort this sequence, it works pretty well on all tests i found. Any ideas why it works wrong on test 4? using System; using System.Linq; namespace Таблица_результатов { class Program {
static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] lines = new string[n]; for (int i = 0; i < n; i++) { lines[i] = Console.ReadLine(); }
var a = lines .Select(x => x.Split()) .ToArray() .OrderByDescending(x => x[1]);
foreach (var x in a) { Console.WriteLine(x[0] + " " + x[1]); } } } } Looks like you are sorting by M string representation Try test 3 1 1 2 100 3 2 Yeah, you are right, thanks for answering, now it passes the test. P.S. Fixed by replacing .OrderByDescending argument with (x => int.Parse(x[1])) if someone's interested. | | Accepted | Shen Yang | 1374. Misere | 18 Oct 2016 04:42 | 1 | another easy 10000+ problem..haha | | for WA 26 | Arseny Babushkin (aytel) | 1684. Jack's Last Word | 17 Oct 2016 20:10 | 1 | for WA 26 Arseny Babushkin (aytel) 17 Oct 2016 20:10 don't use hashes with modulo = 2^32, change it to 10^9 + 7 | | WA#52 | Babies | 1428. Jedi Riddle | 16 Oct 2016 19:44 | 2 | WA#52 Babies 20 Apr 2013 22:56 Hi, i have problem with WA#52, I used long long and test 1 1 32 => accept. This's my code : #include <iostream> using namespace System; using namespace std; long long func( long long x , int po ); void main() { long long a,b,c,y,k,x,n,m; cin>>a>>b>>c; k = (c-1)/a; m = (c-1)/b; x = func( k ,2 ); y = func( m , 2 ); printf("%lld\n%lld\n2",x,y); system("pause"); } long long func( long long x , int po ) { long long temp=2; for( int i=1; i<x; i++ ) { temp *= po; } return temp; } Re: WA#52 Combatcook [YarSU] 🐸 16 Oct 2016 19:44 Hi, I had WA 52 too, these tests helped me: 1) 1 1 1 2) 5 10 1 Edited by author 16.10.2016 19:50 | | Algorithm | monsky | 1002. Phone Numbers | 16 Oct 2016 17:47 | 1 | It's not so interesting to publish ready code, but for those who stuck on this problem the following algorithm could be useful: 1. First of all, build generator, that will generate random tests with specified phone number length and number of words. It will helpful, since you don't know, which tests are runned when you send you code for check. 2. Convert your words to digits and remove those of them that aren't contained in phone number. Also remove duplications that can appear after this converting. During this process build dictionary that will contain converted word as a key, and original word as a value. Last one will be needed to output the result. 3. Sort converted words by length in descendent order. 4. Take every converted word and find all its inclusions to the phone number. Build dictionary that will contain found index as key and list of converted words as value. 5. Now use recursive function which initially will get index=0 as argument, find all words from dictionary for the index and loop them, taking their length to get next index. If next index equals phone number length, you found one of the solutions. 6. Optimize the function to eleminate redundant calls. I mean, on specific step you can check if the next searched solution is expected to be better than found one or not. I'm not sure that this algorithm is the best, but at least I got "accepted" on C# with 600 ms performance. | | Little Hint with mathematics | Mickkie | 1430. Crime and Punishment | 16 Oct 2016 12:51 | 2 | My approach divides into 2 cases I) A>= sqrt(N) or B>=sqrt(N) this can be solved by brute force in O(sqrt(N)) II) A<sqrt(N) and B<sqrt(N) now this is more interesting in case of gcd(A,B)=1 you can proof that there exist x,y>=0 that A*x+B*y = N since A*x congruent to N (mod B) -> x = N*inv(A,B) % B hence 0<=x<=B-1 but B<sqrt(N) and A<sqrt(N) then A*x < N so y >= 0 in case of gcd(A,B)>1 that's your work! :) | | What's wrong with my code on C(and me)? | Dark_Mind | 1001. Reverse Root | 16 Oct 2016 12:46 | 3 | My program answer true for input from example(for big number too), but i get "Wrong answer" on test 1. #include <stdio.h> #include <math.h> #define N 1000000 int main(int argc, char **argv) { long long int array[N]; int i=0; while (scanf("%Ld", &array[i])>0) { i++; } for(i-=1;i>=0;i--) printf("%.4f\n", sqrt(array[i])); return 0; } 1) Try scanf "%lld". 2) DONT try allocate such big arrays on stack. Place your array outside function/in heap/use vector 1)Thank you! Ofc, lld for long long... 2)Yes, its just a test. | | all 12534 difficulty is reading comprehension | Shen Yang | 1555. Find the Treasure! | 16 Oct 2016 11:23 | 1 | I don't think problem statement is clear.. and obviously algorithm difficult is far not worth than 10000+ reading comprehension is possible Edited by author 16.10.2016 11:24 Don't use scanf !!!!!! Edited by author 16.10.2016 18:23 | | Why is answer 1 for a=2 and b=4 correct??? and 50 for 100 200? | prime | 1327. Fuses | 16 Oct 2016 00:11 | 3 | For 2 4 it should be days 2 and 4. For 100 200 it shoould be 100, 102...148(count must be 25 already)...200(count is 51). Janus brokes fuses every ODD day. There is 1 odd day in interval [2..4] Hmm... I see that I just did not understand the task clearly. For me it was like day 2 is the first day, but it is just the starting point of counting... Thanks. | | WA8 with formulas | Daniel Mahu | 1133. Fibonacci Sequence | 15 Oct 2016 18:47 | 2 | I used the formulas with phi and solved a system of 2 equations to get the coefficients, in python using floats. Any hint why I get WA8? all tests on the forum work. I eventually got AC by trying out several values around the integer the math formula gave and checking each against given initial values. | | WA in C++, why? | Norgar | 1327. Fuses | 15 Oct 2016 15:09 | 3 | Hello! Why I got WA? I can't understand :| IMO this must work... Tnx all. ---------------------------------------------------- dayTotal = (LastDay - FirstDay) + 1; for(counter = 1; counter <= dayTotal; counter++) { n = counter % 2; if(n != 0) fuse++; } ----------------------------------------------------- #include <iostream> int main() { int a,b; int answer=0; std::cin>>a>>b; if(a%2==0)a++; for(int i=a;i<=b;i+=2) answer++; std::cout<<answer; return 0; } JDBaha your solution is wrong. for 2 4 it says 1. Edited by author 15.10.2016 15:10 Edited by author 15.10.2016 15:10 | | Why first sample is 5 | Shen Yang | 1555. Find the Treasure! | 15 Oct 2016 11:19 | 1 | I think it takes first player 5 turns to get '*', and 3 turns to move outside,it is at least 8 turns. why is 5 turns? | | I don't know where is wrong. ( Pascal ) | Babin Alexander | 1025. Democracy in Danger | 14 Oct 2016 22:41 | 2 | Wrote on Pascal: var i, j: integer; ms, a, b: integer; arrg: array of integer; begin Read(ms); SetLength(arrg, ms);
for i := 0 to arrg.Length - 1 do begin var temp: integer; Read(temp); arrg[i] := temp; end;
for j := 1 to arrg.Length - 1 do for i := 1 to arrg.Length - j do if arrg[i - 1] > arrg[i] then Swap(arrg[i - 1], arrg[i]);
a := arrg.Length div 2;
for i := 0 to a do b := b + arrg[i] div 2 + 1;
Write(b); end. Wrong answer ( test 1 ). arrg.Length it may be odd | | a hint | Михаил Аршинов | 1217. Unlucky Tickets | 14 Oct 2016 21:08 | 2 | a hint Михаил Аршинов 14 Oct 2016 21:07 long ans[] = new long[23]; ans[2]=lim[2]; for (int i=4; i<=20; i+=4) { int half=i/2; ans[i]=lim[half]*lim[half]; ans[i+2]=lim[half]*lim[half+2]; } System.out.println(ans[N]); lim stands for the "lucky in Moskva" | | Память | artxc | 1086. Cryptography | 13 Oct 2016 13:44 | 2 | Память artxc 12 Oct 2016 22:55 Как узнать заранее, сколько выделять ячеек для решета? > Then k positive integers follow (one in each line). The numbers don't exceed 15000. So you will be asked for not more then 15000th prime. You can find it by brute force, by some prime table etc. My AC program thinks it is 163841. | | I got AC yesterday.I changed my solution but got WA on test 2.what is test 2? | yskyskyer123 | 1519. Formula 1 | 13 Oct 2016 03:07 | 2 | It looks like something is wrong with tests. Test 2 is the second sample but the answer 6 is not accepted! | | WRONG answer 5 | jakhongir | 1723. Sandro's Book | 12 Oct 2016 23:41 | 1 | #include <bits/stdc++.h> using namespace std; const int N = 112345; int a[N]; int b[N]; main() { string s, t; cin >> s; int cnt = 0; int mx=0; int l=0; int cnte=0; for(int i = s.size() - 1; i >= 0; i --) { t = s[i] + t; a[0] = 0; for(int j = 1; j < t.size(); j ++) { int x = a[j - 1]; while(x > 0 && t[x] != t[j]) x = a[x - 1]; if(t[x] == t[j]) x ++; a[j] = x; mx = max(mx, a[j]); } b[i]=mx; if(mx==0)cnte++; mx=0; } if(cnte==s.size()){cout<<s;return 0;} else for(int i=0;i<s.size();i++){if(b[i]>=1)cout<<s[i];} } // any suggestion guys I have no idea what can be the fifth test thanks in advance |
|
|