Общий форум| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | | PLS Help me someone ! What is the problem here... | AAA | 1001. Обратный корень | 2 фев 2014 21:07 | 2 | #include <stdio.h> #include <math.h> int main(void) { long long number[1000000]; int i=0,k; while(scanf("%lld", &number[i++]) == 1); k=i-1; while(k>0) { printf("%.4lf\n", sqrt((double)number[--k])); } return 0; } while(scanf("%lld", &number[i++]) != EOF){/*...*/} | | why WA? | Asif Mahmud | 1001. Обратный корень | 2 фев 2014 21:06 | 5 | why WA? Asif Mahmud 24 фев 2013 19:18 #include<stdio.h> #include<math.h> unsigned long long int a,i,s[10000000]; int main() { double b; i=0; //freopen("input.txt","r",stdin); while(scanf("%llu",&a)!=EOF) { s[i]=a; i++; } while(i>0) { i--; b=sqrt(s[i]); printf("%.4lf\n",b); } return 0; } Plz use "%.4f" instead "%.4lf" to printf. :) why %.4lf is not acceptable? you are fool? this is no need reason ,this is fixed 格式 To use sqrt() from math.h you need to add -lf flag while compiling, I believe. | | g++ 4.7.2 Got Runtime error (access violation) on first test | Gandalf Popstar | 1001. Обратный корень | 2 фев 2014 19:46 | 2 | Can`t understand what is the problem #include <stdio.h> #include <math.h> int main() { unsigned long long int a[4096], b; int counter=0; while(scanf("%llu", &b)) { a[counter]=b; counter++; }
for(int i=counter-1; i>=0; i--) printf("%.15Lg\n", (long double)sqrt(a[i])); return 0; } 1) while(scanf("%llu", &b) != EOF) 2) Maybe it's ok, but why do you printf("%.15Lg\n)? 4 symbols after the dot is not ennough, or I don't understand sth? | | WA5 / Сan somebody tell whether it may be several current users at once? | bulka94 | 2002. Тестовое задание | 2 фев 2014 19:13 | 2 | Сan somebody tell whether it may be several current users at once? Может кто нибудь сказать, может ли быть несколько текущих пользователей сразу? Edited by author 01.02.2014 02:35 Yep, there must be an array with all active users. Нужен будет еще один массив для записи текущих (login) пользователей, у кого будет выбивать WA5. | | give me a hint, please... | BORODA | 1776. Праздничный фейерверк | 2 фев 2014 04:02 | 4 | I tried to solve it with (dp[i] = sum_j(max(dp[j - 1], dp[i - j])) + 10) formula, but the way of getting the math expectation as max(dp[A], dp[B]) isn't right. Ho to do it? What is the formula..? please, help me... :( Add one more dimension to your DP oough, I still cant get it. What is the 2nd dimension? I divide the current line(C) to A and B... I really cant understand what else should I know or do to calc C. What else? You should actually know what is max you're trying to find expectation of! | | Wrong answer_____Паскаль | Айарпи | 1001. Обратный корень | 31 янв 2014 19:11 | 4 | В FPC все работает, здесь же ... Вот код, помогите program f1; var f,f2:text; i,j:integer; a:array[1..130000] of real; begin assign(f,'input.txt'); reset(f); i:=0; While not eof(f) do begin inc(i); read(f,a[i]); end; close(f); assign(f2,'output.txt'); rewrite(f2); For j:=i downto 1 do writeln(f2,sqrt(a[j]):0:4); close(f2); End. 1) Статический массив? Зачем? Динамика тут идет гораздо лучше. 2) Файлы лучше использовать с директивой, т.к. местная проверочная система использует ввод с клавиатуры. здесь нельзя работать с файлами | | For everyone who thinks that his solution( C++ ) is correct, but has TLE.. | PersonalJesus | 1684. Последнее слово Джека | 30 янв 2014 23:22 | 5 | Do NOT use STL's strings, use standart C char arrays instead. That makes a HUGE difference in the time and memory complexity. I hope that this will be helpful to somebody:) i disagree, my solution takes 0.046 seconds... and i use string, vector Do NOT use STL's strings, use standart C char arrays instead. That makes a HUGE difference in the time and memory complexity. I hope that this will be helpful to somebody:) STL string - TL 12, 10 MB used. Char arrays - AC 0.031, 1.24 MB used... I got TLE. But after changing "s1.size()" on "long ns1 = s1.size()" and "s2.size()" on "long ns2" got AC. =) And I changed "vector" on "deque"( for deleting elements from begining ). Edited by author 14.12.2011 16:27 Edited by author 14.12.2011 16:30 Got 0.062 and 1485 KB with pure STL and strings: just start your program with cin.sync_with_stdio(false); Btw, to get a O(n) solution consider that if a suffix of the last word is a prefix of the first word (check thru hash), then it is safe to assume that this suffix is in the answer. | | What shape is the football gate? | Nodir NAZAROV Komiljonovich | 1874. Футбольные ворота | 30 янв 2014 20:15 | 1 | I tried to figure it out, how 1 tree and two sticks with the length of 2 can form the area more than 4? The largest area would be rectangle. What is the trick on this problem, can anybody explain with Geometry language. Thanks. Edited by author 30.01.2014 20:18 | | Incorrect output ? | Martynas | 1068. Сумма | 30 янв 2014 20:05 | 1 | It keeps saying that my program produces incorrect solutions. Anyone else is having the same issue? #include <stdlib.h> #include <stdio.h> int main() { int start, change, N, sum; scanf("%d", &N); if (abs(N) <= 10000) { change = N > 1 ? 1 : -1; for (start = 1; start != (N + change); start += change) sum += start; printf("%d\n", sum); } return 0; } | | What here not so? | Kseniya | 1068. Сумма | 30 янв 2014 19:48 | 2 | #include <iostream> #include <math.h> using namespace std; int main(int argc, char* argv[]) { int N,Sum=0; cout<<"Введите значение"<<endl; cin>>N; if(N>0 && N<=abs(1000)) { for(int i=0;i<=N;i++) { Sum+=i; } cout<<Sum; } if(N<0 && N<=abs(-1000)) { for(int j=0;j>=N;j--) { Sum+=j; } cout<<Sum; } getch(); return 0; } Edited by author 05.07.2013 20:36 Edited by author 05.07.2013 20:38 from the first glance: it's supposed to be 10000, not 1000 | | Hint Test #5 | Alexandru Valeanu | 1627. Join | 30 янв 2014 12:38 | 1 | The Laplacian matrix does not have always N * M lines/columns. | | To admins | Vitaliy | 1290. Саботаж | 30 янв 2014 08:53 | 1 | Извените, чо пишу на русском - по другому не умею. По поводу теста №2, в котором на вход подается 0, а правильным решением является пустая строка. Лично мое мнение: результатом должен быть массив длиной 1 с первым элементом равным 1. Объясню: В условии задачи сказано, что входными данными являются число N(длина массива) и элементы этого массива. Предполагается, что N может быть равно 0. Массив поступает в функцию, которая возвращает массив, первым элементом которого является длина входного массива. Из этого можно зделать вывод, что, если на вход задачи может поступить массив, у которого указана длина 0, то и функция при обрабоке этого массива должна вернуть массив длиной 1 с первым элементом равным длинне массива, тоесть 0. После обработки этого массива функцией и получится массив длиной 1 с первым элементом равным 1. Лично я не догадался, что результатом будет пусая строка (пришлось подсмотреть на форуме). | | Nodejs Support | Trung Phan | | 30 янв 2014 08:36 | 1 | Will Timus Online Judge support Nodejs? | | WA2 | Vetriti | 1987. Вложенные отрезки | 30 янв 2014 04:08 | 1 | WA2 Vetriti 30 янв 2014 04:08 | | WA5 | kilik | 1360. Философский спор | 29 янв 2014 18:34 | 2 | WA5 kilik 7 дек 2013 01:52 #include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() { double t = 0; double eps; double x, y; cin>>x>>y>>eps; eps=eps*0.001; while(1) { double c = cos(t) - y; double d = sin(sqrt(t)) - x ; if( c*c+d*d > eps/2) t+=0.007; else { break; } } cout<<fixed<<setprecision(5)<<t; return 0; } Can someone tell what is wrong or give some tests?(my mail kilik94@yandex.ru) Thanks in advance! Edited by author 07.12.2013 01:58 Why "> eps/2" ? May be "> eps**2"? | | Wrong answer | Leonid | 1394. Корабли. Версия 2 | 29 янв 2014 01:22 | 2 | How to solve this problem? Edited by author 29.09.2013 08:45 Edited by author 29.09.2013 08:45 | | How to pass TL. test #10 | tanas | 1700. Пробуждение | 28 янв 2014 20:57 | 3 | I used such variables: map<string,int> id; set<string> list[1003]; map<string,int> mp; vector<string> res; but got TL test 10. Can i get AC with same solution? Yes if instead string use struct{ int num; int row; int poz1; int poz2; }; to have deal with segments of char S[1000][125] to pass test 10 you must do 1) compare hash codes instead of string compare 2) use vectors+sort. In this case vector is way faster than std::set 3) fast I/O. 4) fast list intersection good luck! | | WA3 | Vetriti | 1998. Старый падаван | 28 янв 2014 20:30 | 2 | WA3 Vetriti 28 янв 2014 20:21 If you have WA3 try this: 1 3 5 1 4 5 7 Right answer is 1 WA6 Vetriti 28 янв 2014 20:30 If you have WA6 try to change sum<k to sum<=k. It helped me. Edited by author 28.01.2014 20:34 | | There is a O(9973) solution without precalculation (+) | Michael Rybak (accepted@ukr.net) | 1309. Искусство спора | 28 янв 2014 20:10 | 8 | There *is* a period of 9973, but not for the given function. Let's denote 9973 as M. ////////////////////////////////////////////////////////////////////////// //In short//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// 1. g(n) is linear by f(n - 1), and g(x, y) = g(x mod M, y), which means we can find such A and B (in O(M)) that f(x + M) = (A * f(x) + B) mod M. 2. Having found such A and B, it's easy to show that for p > 0, f(p * M) = B * (A^(p-1) + A^(p-2) + .. + A^2 + A + 1) mod M. I'm not sure if the last sum can be calculated in O(1), but it surely can be found in O(M). 3. So, we calc A and B, read N, find f(N - N % M) and then iterate till N in O(M), resulting with overall O(M). ////////////////////////////////////////////////////////////////////////// //In detail/////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// ////// //1.// ////// Let's assume we know f(i) and wish to find f(i+1). Easy to see, g(x, y) = g(x mod M, y). This is why, f(i + 1) = g(i + 1, f(i)) = g((i + 1) mod M, f(i)). Let's denote (i + 1) mod M as j. f(i + 1) = g(j, f(i)) = ((f(i) - 1) * j^5 + j^3 – j * f(i) + 3 * j + 7 * f(i)) mod M f(i + 1) = f(i) * (j^5 - j + 7) + (-j^5 + j^3 + 3 * j) mod M f(i + 1) = f(i) * ((j^5 - j + 7) mod M) + (-j^5 + j^3 + 3 * j) mod M Remembering that j = (i + 1) mod M, let us denote U(i) = (j^5 - j + 7) mod M, V(i) = (-j^5 + j^3 + 3 * j) mod M. As a result: f(i + 1) = U(i) * f(i) + V(i) Note that for any i, we calculate U(i) and V(i) in O(1) time. Also note that U(i) = U(i mod M) and V(i) = V(i mod M): f(i + 1) = U(i mod M) * f(i) + V(i mod M) Let's consider some certain x, and let's denote f(x) as X. f(x+0) == X == 1 * X + 0 == (a0 * X + b0) (mod M) f(x+1) == U(0) * f(x+0) + V(0) == (a1 * X + b1) (mod M) f(x+2) == U(1) * f(x+1) + V(1) == (U(1) * a1) * X + (U(1) * b1 + V(1)) == (a2 * X + b2) (mod M) f(x+3) == U(2) * f(x+2) + V(2) == (U(2) * a2) * X + (U(2) * b2 + V(2)) == (a3 * X + b3) (mod M) f(x+4) == U(3) * f(x+3) + V(3) == (U(3) * a3) * X + (U(3) * b3 + V(3)) == (a4 * X + b4) (mod M) ... f(x+M) == (aM * X + bM)) (mod M) Note that aM and bM do not depend on x - this is the key point! Let's denote aM as A and bM as B. Each iteration above needs O(1) time, so we found A and B in O(M), such that for any x, f(x+M) = (A * f(x) + B) mod M ////// //2.// ////// Consider the following sequence f(0 * M) == 0 (mod M) f(1 * M) == A * f(0 * M) + B == B (mod M) f(2 * M) == A * f(1 * M) + B == A * B + B == B * (A + 1) (mod M) f(3 * M) == A * f(2 * M) + B == A * B * (A + 1) + B == B * (A^2 + A + 1) (mod M) ... f(p * M) == B * (A^(p-1) + A^(p-2) + .. + 1) (mod M) Function A^p mod M is periodic by p with period being divisor of M, so we can easily calculate f(p * M) in O(M) time by summing up first M items of the sequence above. Moreover, for this particular problem p (see below) is very small - less than N/M, so we may calculate this sum explicitly. ////// //3.// ////// The most pleasant part. Given N, we set p to N / M, and calculate f(p * M) with the method desribed above. N - p * M < M, so all we have to do left is explicitly apply the initial formula N - p * M times to find f(N). Edited by author 15.02.2006 18:23 that is the best solution i've ever seen ,thank you Can you explain why did you decide that the coefficients aM and bM don't depend on x? That's right I guess, but it's not evident for me. Why g(x,y) = g(x mod M,y) Correct me if I am mistaken but I think this is because U(i) = U(i mod M) and V(i) = V(i mod M). | | WA4 - more tests ! Please ! | Vanakals | 1607. Такси | 28 янв 2014 19:34 | 1 | Please give me some more tests. And what is the test number 4? |
|
|