Общий форумmore than one registrations ;) who can help me? I WA on #7.Why? here is my program: var a:array[1..1000]of longint; b:array[1..1000,1..1000]of boolean; n,i,j,x,y,m:longint; c:boolean; function find(x,y:longint):boolean; var i:longint; begin if b[x,y] then exit(false); for i:=1 to m do if (b[a[i],x])and(b[a[i],y])then begin b[x,y]:=true;b[y,x]:=true; exit(false); end; exit(true); end; begin while not seekeof do begin readln(x,y); b[x,x]:=true;b[y,y]:=true; b[x,y]:=true;b[y,x]:=true; c:=true; for j:=1 to m do if a[m]=x then begin c:=false;break;end; if c then begin inc(m);a[m]:=x; for i:=1 to m do if find(a[i],x) then begin writeln(0);halt; end; end; c:=true; for j:=1 to m do if a[m]=y then begin c:=false;break;end; if c then begin inc(m);a[m]:=y; for i:=1 to m do if find(a[i],y) then begin writeln(0);halt; end; end; end; writeln(1); end. Pls check for the following case: 5 6 5 8 5 9 6 7 8 9 9 10 Answer should be 1 Test 7 has invert vertexes. 10 1 1 2 asn: 1 I have many times WA, because my programm doesnt check it. [code deleted] Edited by author 10.09.2012 19:45 Edited by moderator 20.11.2019 00:11 OMG,how it was possible to come up with that? you should cout the answer only, without any "The minmum no of voters needed is" n = 3 1 2 0 0 2 3 0 0 0 3 1 0 n = 6 1 2 3 0 0 0 3 4 5 0 0 0 0 5 6 1 0 0 0 0 6 2 4 0 n = 10 1 2 3 4 0 0 0 0 4 5 6 7 0 0 0 0 0 7 8 9 1 0 0 0 0 0 9 10 2 5 0 0 0 0 0 10 3 6 8 0 n = 15 1 2 3 4 5 0 0 0 0 0 5 6 7 8 9 0 0 0 0 0 0 9 10 11 12 1 0 0 0 0 0 0 12 13 14 2 6 0 0 0 0 0 0 14 15 3 7 10 0 0 0 0 0 0 15 4 8 11 13 0 n = 21 1 2 3 4 5 6 0 0 0 0 0 0 6 7 8 9 10 11 0 0 0 0 0 0 0 11 12 13 14 15 1 0 0 0 0 0 0 0 15 16 17 18 2 7 0 0 0 0 0 0 0 18 19 20 3 8 12 0 0 0 0 0 0 0 20 21 4 9 13 16 0 0 0 0 0 0 0 21 5 10 14 17 19 0 n = 36 1 2 3 4 5 6 7 8 0 0 0 0 0 0 0 0 8 9 10 11 12 13 14 15 0 0 0 0 0 0 0 0 0 15 16 17 18 19 20 21 1 0 0 0 0 0 0 0 0 0 21 22 23 24 25 26 2 9 0 0 0 0 0 0 0 0 0 26 27 28 29 30 3 10 16 0 0 0 0 0 0 0 0 0 30 31 32 33 4 11 17 22 0 0 0 0 0 0 0 0 0 33 34 35 5 12 18 23 27 0 0 0 0 0 0 0 0 0 35 36 6 13 19 24 28 31 0 0 0 0 0 0 0 0 0 36 7 14 20 25 29 32 34 0 why? n=10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 9 10 1 10 ---- 9>6 is it wrong, why? Edited by author 18.04.2009 00:35 Edited by author 26.11.2010 13:52 Probably easier to grasp: n=10 5 4 1 2 3 4 4 1 5 6 7 4 2 5 8 9 4 3 6 8 10 4 4 7 9 10 n=15 6 5 1 2 3 4 5 5 1 6 7 8 9 5 2 6 10 11 12 5 3 7 10 13 14 5 4 8 11 13 15 5 5 9 12 14 15 Thanks to author! Edited by author 19.11.2014 21:49 Maybe, you know some tricks? input 6 00:00:00 00:00:01 00:00:02 00:00:03 00:00:04 00:13:00 AC output 00:13:58 00:13:58 00:13:58 00:13:58 00:13:58 00:16:46 perhaps you meant this test? 6 00:00:00 00:00:01 00:00:02 00:00:03 00:00:04 00:00:05 my output WA5 00:13:58 00:13:58 00:13:58 00:13:58 00:13:58 00:15:48 why 00:16:46? Can someone please explain this to me. See, kettles number 1 - 5 will drink coffee at the same time (00:13:58) and only in this time kettle number 6 may begin to boil water for himself ..... He will need 2:48 seconds for that. Why 2:48 ? ...... because in this time 200 ml water will be in the kettle with 20 degrees .... but kettle number 6 want 100 degrees in the main kettle .... then we take: deltaT = 100 - 20 = 80 C and P you know from statement m = 200 using formula from statement (deltaT = P * littleT / C * m) we will take that littleT = deltaT * C * m / P = 02:48 --- this is time that we need to boil water. Result : 00:13:58 + 00:02:48 = 00:16:46 #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){/*...*/} #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. 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? С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. 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! В 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) Файлы лучше использовать с директивой, т.к. местная проверочная система использует ввод с клавиатуры. здесь нельзя работать с файлами 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. 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 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; } #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 The Laplacian matrix does not have always N * M lines/columns. Извените, чо пишу на русском - по другому не умею. По поводу теста №2, в котором на вход подается 0, а правильным решением является пустая строка. Лично мое мнение: результатом должен быть массив длиной 1 с первым элементом равным 1. Объясню: В условии задачи сказано, что входными данными являются число N(длина массива) и элементы этого массива. Предполагается, что N может быть равно 0. Массив поступает в функцию, которая возвращает массив, первым элементом которого является длина входного массива. Из этого можно зделать вывод, что, если на вход задачи может поступить массив, у которого указана длина 0, то и функция при обрабоке этого массива должна вернуть массив длиной 1 с первым элементом равным длинне массива, тоесть 0. После обработки этого массива функцией и получится массив длиной 1 с первым элементом равным 1. Лично я не догадался, что результатом будет пусая строка (пришлось подсмотреть на форуме). Will Timus Online Judge support Nodejs? |
|