Общий форум| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | | what's wrong with that code :( | Bartosz | 1053. Пиноккио | 7 янв 2010 23:47 | 1 | #include <cstdlib> #include <iostream> //----------Funkcje---------------------------- long long nwd(long long a, long long b) { if (b>=1) nwd(b, a%b); if (b=0) return a; } using namespace std; //---------------Program------------------------------------ int main(int argc, char *argv[]) { int n; long long tab[1002]={0}; //printf("Dla ilu liczb chcesz policzyc NWD?: \n"); scanf("%d", &n); //printf("Podaj liczby: \n"); for (int i=0;i<n;i++) scanf("%I64d", &tab[i]); long long wynik=tab[0]; for (int i=0;i<n-1;i++) { wynik=nwd(tab[i],tab[i+1]); tab[i+1]=wynik; }
//printf("NWD wynosi %I64d \n", wynik); printf("%I64d", wynik);
system("PAUSE"); return EXIT_SUCCESS; } | | I have WA8. Give me some tests. | AiD | 1500. Разрешения на проезд | 7 янв 2010 19:20 | 5 | Give me some tests or write if there are some sly tests. I solve this problem by 2^K*N*N. I have the same problem. Where is bag? Edited by author 09.07.2008 23:49 Also WA8. Give some tests WA8. Small Code, but can not find any bug/ [code cut] Edited by moderator 18.04.2013 21:14 My solution is O(2^k). I think, that main problem's are - how reduce amount of DFS (check the route existence's with current set of licenses) and reduce brute-force to find all possible combinations of licenses. Binary search for number of licenses helped me to avoid TLE. Edited by author 08.01.2010 01:39 | | Why my code WA#7>????? Need help?Who know the test for #7? | zslwyuan | 1036. Счастливые билеты | 6 янв 2010 18:55 | 2 | type sl=array[1..150] of longint; var i,j,k,l,n,m,s:longint; f:array[0..50,-10..1000] of sl; u:sl; function gjc(a:sl):sl; var i,t:longint; tmp:sl; begin for i:=120 downto 1 do if a[i]<>0 then break; t:=i; fillchar(tmp,sizeof(tmp),0); for i:=1 to t do for j:=1 to t do inc(tmp[i+j-1],a[i]*a[j]); for i:=1 downto 120 do begin tmp[i+1]:=tmp[i+1]+tmp[i] div 10000; tmp[i]:=tmp[i] mod 10000; end; exit(tmp); end; procedure gjj(b:sl;var a:sl); var i,j,k,l:longint; begin for i:=1 to 120 do a[i]:=a[i]+b[i]; for j:=1 to 120 do begin inc(a[j+1],a[j] div 10000); a[j]:=a[j] mod 10000; end; end; procedure printgj(a:sl); var i,j,k,l,len:longint; st:string; begin i:=120; while (i>0)and(a[i]=0) do dec(i); if i=0 then BEGIN writeln(0);exit;end; len:=i-1; write(a[len+1]); for i:=len-1 downto 1 do begin str(a[i],st); while length(st)<4 do insert('0',st,1); write(st); end; end; begin readln(n,s); if (n=1)and(s<=9) then begin writeln(1);halt; end; if s mod 2=1 then begin writeln(0);halt; end; f[0,0][1]:=1; for i:=1 to n do for j:=0 to s shr 1 do for k:=0 to 9 do begin gjj(f[i-1,j-k],f[i,j]); end; l:=s shr 1; u:=(gjc(f[n,l])); printgj(u); end. Edited by author 07.01.2010 10:17 | | why not? | luckysundog | 1007. Кодовые слова | 6 янв 2010 07:48 | 2 | test: 4 0000 011 1011 11011 answ: 0000 0111 1010 1101 is it correct or not? lol, i calculated sum of ALL positions | | WA#3 | [МУПОЧ "Дубна"] Jester | 1100. Таблица результатов | 6 янв 2010 03:05 | 1 | WA#3 [МУПОЧ "Дубна"] Jester 6 янв 2010 03:05 What does mean WA3 Crash (access violation)? I compiled my program many times in dev-C++ and VC++. Then I try to write #pragma comment(linker, "/STACK:16777216") but it doesn't work. I use dynamic array and sheker sort. | | And where is my mistake? | Radchenko Evgeniy | 1005. Куча камней | 6 янв 2010 00:38 | 3 | program stone; const nmax=20; var i,k,n:byte; x:longint; a:array[1..nmax] of longint; begin read(n); For i:=1 to n do read(a[i]); For i:=2 to n do For k:=n downto i do If a[k-1]>a[k] then begin x:=a[k]; a[k]:=a[k-1]; a[k-1]:=x; end; while n>1 do begin a[n-1]:=a[n]-a[n-1]; dec(n); For i:=2 to n do For k:=n downto i do If a[k-1]>a[k] then begin x:=a[k]; a[k]:=a[k-1]; a[k-1]:=x; end; end; write(a[1]); read; end. May be I am too self-confident, but I am sure my program must work. But the fifth test refutes my confidence. If you are able to help, please,try to find mistake and write where it is=) Your algo is incorrect. Test: 5 3 3 3 4 5 Answer: 0 Thank you, I understood, I will at a new algo. | | Please help WA#1 | Nisarg Shah | 1102. Странный диалог | 5 янв 2010 23:39 | 3 | I used getc and the idea of finite automaton to solve this problem and my program is working fine on the sample test case as well as all test cases given in thread. Still I am getting WA#1. I know it is not same as sample case. Please give me some good test from case 1. Thanks. I have used getc(stdin), but if I give input from file by <<, I have to put an extra getc(stdin), whereas if I write it on command prompt, that is not required. Why is this so? Why input from file has an extra character at end of line? I thought that in the end of n-th line it is EOF. But this line finishes by '\n' similarly as another lines. That's why I got WA#1. | | Why? | [МУПОЧ "Дубна"] Jester | 1001. Обратный корень | 4 янв 2010 18:33 | 2 | Why? [МУПОЧ "Дубна"] Jester 4 янв 2010 18:06 Why this #include <math.h> #include <iostream> #include <iomanip> #include <vector> using namespace std; int main() { vector<double> numbers; double number = 0; while(cin >> number){ numbers.push_back(number); }
for(int i = numbers.size() - 1; i >= 0 ; i--){ cout<<setprecision(5)<<sqrt(numbers[i])<<'\n'; }
return 0; } is wrong and this //... printf("%.4lf\n", sqrt(numbers[i])); //... is write? I don't understand. Both ways are correct... I don't know C++ a lot, but I think setprecision(5) means at most 5 digits. So use this instead and be happy: cout<<setprecision(5)<<setiosflags(ios::fixed)<<sqrt(numbers[i])<<'\n'; in which setiosflags(ios::fixed) means there must be 5 digits, filling with zero, which will satisfy the judge. Edited by author 04.01.2010 18:41 Edited by author 04.01.2010 18:42 | | Why WA2??? | sokoL[TSOGU™] | 1226. йынтарбО кодяроп | 4 янв 2010 10:41 | 2 | #include<stdio.h> #include<iostream> using namespace std; char str[300],text[3000005],c,ch; int n=-1,i=0,cnt=-1; int main() { #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif while(scanf("%c",&c)!=EOF) { n++; text[n] = c;
} while(i<n) { memset(str,'\0',sizeof(str)); cnt= -1; while(1) { if((text[i]>='a'&&text[i]<='z')||(text[i]>='A'&&text[i]<='Z')) { cnt++; str[cnt] = text[i]; i++; } else { ch = text[i]; i++; break; } } for(int j=cnt;j>=0;j--) { printf("%c",str[j]); } printf("%c",ch); } return 0; } i WA#2,too. what's the test? Edited by author 04.01.2010 10:42 | | why | forzm | | 2 янв 2010 13:54 | 3 | why forzm 6 дек 2009 14:24 Re: why SuperLight 2 янв 2010 13:54 | | Give me some tests | Duzhy Igor | 1210. Добрые духи | 31 дек 2009 23:43 | 3 | I think that my program is correct, but i don't understand why i have WA#5. I use Dejkstra algorithm. Please, give me some right tests. Than I use another method - DP. I use 2 arrays for the current and previous states, but I have WA#7. Help!!! Thanks. Edited by author 06.10.2006 22:31 Edited by author 06.10.2006 22:31 Edited by author 06.10.2006 22:31 As i know - Dejkstra dosn't work for graph with negative weight of edge. 3 2 1 15 0 1 5 0 * 4 1 -5 2 10 0 1 3 0 2 40 0 0 * 3 1 1 2 5 3 -5 0 2 -19 3 -20 0 4 -100 0 Answer is -1 | | Welcome back to Timus Onlune Judge! | Vladimir Yakovlev (USU) | | 31 дек 2009 18:51 | 6 | New Year wonders? :) IMHO it is one of the best present to all Timus authors :) Happy New Year, Timus ! Edited by author 30.12.2009 18:49 Yeahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh I wish all authors outstanding achievements in a New Year! | | Why I WA for the text one?But i have passed the example text? | zslwyuan | 1094. Дисплей | 31 дек 2009 10:44 | 2 | var s:array[1..100010] of char; i,j,k,l,now,lo:longint; a,t1,t2:string; begin a:=''; for i:=1 to 80 do a:=a+' '; i:=0; while not(eof) do begin inc(i);read(s[i]); end; lo:=i; now:=1; for i:=1 to lo do begin if (s[i]='<') then begin dec(now); if (now=0) then now:=1; continue; end; if (s[i]='>') then begin inc(now); if (now=81) then now:=1; continue; end; if now=1 then t1:='' else t1:=copy(a,1,now-1); if now=80 then t2:='' else t2:=copy(a,now+1,80-now-1); a:=''; a:=t1+s[i]+t2; t1:=''; t2:=''; inc(now); if (now=81)then now:=1; end; for i:=1 to 80 do write(a[i]); end. | | For what! | Martin | 1068. Сумма | 5 дек 2009 15:07 | 1 | I used "long long" and got WA; used "int" but got AC! | | help!WA#2 | sokoL[TSOGU™] | 1156. Два тура | 4 дек 2009 23:45 | 1 | #include<stdio.h> #include<iostream> using namespace std; int a,b,n,m,g[1000][1000]; int _max = -1000; int main() { scanf("%d %d",&n,&m); for(int i = 1;i<=m;i++) { scanf("%d %d",&a,&b); g[a][b]=1; g[b][a]=1; } for(int k = 1;k<=2*n;k++) { for(int l = 1;l<=2*n;l++) { if(k==l){continue;} else if(g[k][l]==1) { g[k][l]=2; g[k][l]=2; } } } for(int k = 1;k<=2*n;k++) { for(int l = 1;l<=2*n;l++) { if(k==l){continue;} else if(g[k][l]==0) { g[k][l]=1; g[k][l]=1; } } } int key = 0; for(int k = 1;k<=2*n;k++) { for(int l = 1;l<=2*n;l++) { if(key>=2){return 0;} else if(k==l){continue;} else if(g[k][l]==1) { printf("%d %d\n",k,l); key++; } } } printf("IMPOSSIBLE"); } | | to admins | Progbeat | 1589. Сокобан | 4 дек 2009 11:09 | 8 | i got ac, but my program can't pass some tests.. can you add these tests? Edited by author 19.01.2008 01:06 Yes, send your tests to Sandro at Plotinka Ru and we'll add them. i've sent tests to your mail. have you received them? Can you, please, add my tests too? It seems to me, that they are quite hard. I've sent them to "timus_support@acm.timus.ru". Edited by author 07.11.2009 04:04 Hey, have somebody read my previsious post? Are admins alive? | | 0.001s 227 КБ | Erzhan Shaniev | 1243. Развод семи гномов | 2 дек 2009 22:00 | 3 | var s1,s:string; i,k,x,code:integer; begin read(s); i:=2; s1:=s[1]+s[2]; repeat begin val(s1,k,code); x:=k mod 7; str(x,s1); inc(i); s1:=s1+s[i]; end; until i>=length(s); if s1<>'' then begin val(s1,k,code); x:=k mod 7; end; write(x); end. very simple slish, hare vipendrivats9 #include <stdio.h> #include <string.h> const int d[6] = {1,3,2,6,4,5}; int main() { char s[50]; gets(s); int sum = 0, n = strlen(s); for (int i = n - 1; i >= 0; --i) sum += ( s[i] - '0' ) * d[(n-1-i)%6]; printf("%d", sum%7); } Edited by author 02.12.2009 22:02 | | statement | Tbilisi SU: Giorgi Saghinadze (GVS) | 1035. Вышивка крестиком | 2 дек 2009 17:50 | 2 | statement Tbilisi SU: Giorgi Saghinadze (GVS) 22 май 2009 19:05 I cant understand problem statement , I'm reading it for 1 hour and can't understand what they want ;( please explain it to me... thanks Sorry,it's hard to say in English. | | Answer to this tests pls | Nurtayev Elmurod | 1718. Реджадж | 1 дек 2009 02:07 | 4 | 2 [SPbSU_ITMO]_WiNGeR TL 7 Milanin_(TNU) AC 3 [SPbSU_ITMO]_WiNGeR TL 7 Milanin_(TNU) AC Milanin_(TNU) WA 7 3 [SPbSU_ITMO]_WiNGeR TL 6 Milanin_(TNU) AC Milanin_(TNU) WA 7 3 Milanin_(TNU) WA 6 Milanin_(TNU) WA 6 Milanin_(TNU) WA 7 Thanks 1) 1 2 2) 2 2 3) 1 2 4) 1 1 melkiy! Big thanks for answer it was helped me to get AC! can you send me your solution? grumpy@doda.uz! Thanks... Edited by author 23.10.2009 10:35 Edited by author 23.10.2009 15:49 sorry my bad but I still have WA #3 Edited by author 01.12.2009 02:11 Edited by author 01.12.2009 02:11 | | WA6 | Fyodor Menshikov | 1729. Сундук мертвеца | 1 дек 2009 00:18 | 1 | WA6 Fyodor Menshikov 1 дек 2009 00:18 Test is 10.000 29.999 Correst answer is 60.000583 |
|
|