Show all threads Hide all threads Show all messages Hide all messages |
Page 1 |
Why Compile error ;( | m_frankie | 1025. Democracy in Danger | 3 Sep 2007 22:55 | 5 |
In DevC++ program compile perfect; And it works; but why isn't working in here :[ Please help me... #include<iostream> using namespace std; int main(){ int k,grup[101]; cin >> k; int majority = k/2+1, min[majority],sum=0; for(int i=0;i<k;i++) cin >> grup[i]; int localMin=grup[0], indx=0,H=0; while(H<majority){ for(int i=1;i<k;i++){ if((grup[i]<localMin)&&(grup[i]>0)){ localMin=grup[i]; indx=i; } } min[H]=localMin/2+1; grup[indx]=-2; H++; } for(int i=0;i<majority;i++) sum += min[i];
cout << sum << endl; } i think there isnt any error...................... error: expression must have a constant value int majority = k/2+1, min[majority],sum=0; ^ int min[250]; int majority = k/2+1,sum=0; Edited by author 03.09.2007 23:00 |
What a #%ck( WA 5)? | Narg | 1025. Democracy in Danger | 7 Jun 2005 15:37 | 1 |
Why 2 ABSOLUTELY ideintific soulutions gets different results? Pascal get AC, C gets WA test 5 :(. |
why i have 2 WA already ? | Pavel Martinov [USURT] | 1025. Democracy in Danger | 5 Sep 2005 02:05 | 2 |
Plz help me, i not understand why i have WA. #include <stdio.h> int main() { int i,j=0,tmp,real; int K; int wantnum=0; int grp[101]; scanf("%d",&K); for(i=0; i<K; i++) { scanf("%d",&tmp); if((tmp%2 == 0)) continue; grp[j] = tmp; j++; } real=j; for(i=0; i<K; i++) for(j=0; j<K-i; j++) if(grp[j] > grp[j+1]) { tmp=grp[j]; grp[j]=grp[j+1]; grp[j+1]=tmp; } for(i=0; i<real/2+1; i++) wantnum += grp[i]/2+1; printf("%d",wantnum); return 0; } your bubble sort is not working right. add -1 on the second for check for(i=0; i<K; i++) for(j=0; j<K-i - 1; j++) if(grp[j] > grp[j+1]) { tmp=grp[j]; grp[j]=grp[j+1]; grp[j+1]=tmp; } sorry for my english :P Plz help me, i not understand why i have WA. #include <stdio.h> int main() { int i,j=0,tmp,real; int K; int wantnum=0; int grp[101]; scanf("%d",&K); for(i=0; i<K; i++) { scanf("%d",&tmp); if((tmp%2 == 0)) continue; grp[j] = tmp; j++; } real=j; for(i=0; i<K; i++) for(j=0; j<K-i; j++) if(grp[j] > grp[j+1]) { tmp=grp[j]; grp[j]=grp[j+1]; grp[j+1]=tmp; } for(i=0; i<real/2+1; i++) wantnum += grp[i]/2+1; printf("%d",wantnum); return 0; } Plz help me, i not understand why i have WA. #include <stdio.h> int main() { int i,j=0,tmp,real; int K; int wantnum=0; int grp[101]; scanf("%d",&K); for(i=0; i<K; i++) { scanf("%d",&tmp); if((tmp%2 == 0)) continue; grp[j] = tmp; j++; } real=j; for(i=0; i<K; i++) for(j=0; j<K-i; j++) if(grp[j] > grp[j+1]) { tmp=grp[j]; grp[j]=grp[j+1]; grp[j+1]=tmp; } for(i=0; i<real/2+1; i++) wantnum += grp[i]/2+1; printf("%d",wantnum); return 0; } |
Why WA??? | snipious | 1025. Democracy in Danger | 29 Jan 2005 17:28 | 2 |
const kmax = 101; var n, n2, k, t, i, j: longint; a: array[1..kmax] of longint; begin read(k); for i := 1 to k do read(a[i]); for i := 1 to k - 1 do for j := 1 to k - i do if a[j] > a[j + 1] then begin t := a[j]; a[j] := a[j + 1]; a[j + 1] := t; end; n := 0; for i := 1 to k div 2 + 1 do inc(n, a[i] div 2 + 1); write(n); end. |
Why WA??? | snipious | 1025. Democracy in Danger | 28 Jan 2005 20:38 | 2 |
const kmax = 101; var n, n2, k, t, i, j: byte; a: array[1..kmax] of byte; begin read(k); for i := 1 to k do read(a[i]); for i := 1 to k - 1 do for j := 1 to k - i do if a[j] > a[j + 1] then begin t := a[j]; a[j] := a[j + 1]; a[j + 1] := t; end; n := 0; for i := 1 to k div 2 + 1 do inc(n, a[i] div 2 + 1); write(n); end. |
Can somebody give me some right tests??!!! | sokol | 1025. Democracy in Danger | 15 Jun 2004 15:26 | 2 |
Maybe you should post your mail if you want the tests. I've got them, so... |
why it is wrong???????????? | Aulterman | 1025. Democracy in Danger | 4 May 2004 09:55 | 3 |
var a,b:array [1..101] of longint; k:longint; procedure init; var i:longint; begin fillchar(a,sizeof(a),0); readln(k); for i:=1 to k do read(a[i]); end; procedure work; var k1,t,max,i,j,min,jl:longint; begin k1:=0; max:=0; min:=a[1]; k1:=trunc(k/2)+1; for i:=1 to k-1 do for j:=1 to k-1 do begin if min>a[j+1] then begin min:=a[j+1]; jl:=j+1; end; if j=k-1 then begin b[i]:=min; a[jl]:=10002; min:=a[i]; end; end; for i:=1 to k1 do max:=max+(trunc(b[i]/2)+1); writeln(max); end; begin init; work; end. try test: 6 1 5 9 3 7 11 answer: 10 Why you not sort array??? Sory? but my test is incorrect... try this test 5 3 5 7 9 11 answer: 9 |
read this now !!! | ratrax21 | 1025. Democracy in Danger | 16 Jan 2014 13:47 | 3 |
if you will not send me the answer of this problem i will kick you out of the contest.!! fuc* you! :) if you will not send me the answer of this problem i will kick you out of the contest.!! Edited by author 16.09.2012 00:41 Edited by author 16.09.2012 00:41sorry I was joking. :) Edited by author 16.01.2014 13:50 |
read this! | ratrax21 | 1025. Democracy in Danger | 14 Mar 2003 22:37 | 2 |
if you will not send me the problem I will kick you !!!! Please, describe me at least the way of kicking us! Maybe, you're a dirty stupid telepate? |
fuck you sukers! | ratrax21 | 1025. Democracy in Danger | 14 Mar 2003 22:23 | 4 |
|
fuck you sukers! | ratrax21 | 1025. Democracy in Danger | 14 Mar 2003 15:23 | 1 |
|
| ratrax21 | 1025. Democracy in Danger | 14 Mar 2003 15:21 | 1 |
ratrax21 14 Mar 2003 15:21 |
Why wrong answer??????? | Misha | 1025. Democracy in Danger | 12 Mar 2003 19:44 | 2 |
Why wrong answer??????? Type Vector = array [1..101] of Integer; Var a: Vector; k,i,u,min,R,p,o : Integer; Begin Readln (k); For i:=1 to k do Read (a[i]); u:=1; while (u<=k) do begin min:=a[u]; for i:=u to k do if a[i]<min then begin min:=a[i]; p:=i; end; R:=a[u]; a[u]:=min; a[p]:=R; u:=u+1; end; k:=k div 2+1; o:=0; for i:=1 to k do begin a[i]:=round(a[i]/2); o:=o+a[i]; end; write (o); end. use Div 2 instead of round ... |
help, why it got wa? | BShell | 1025. Democracy in Danger | 19 Jun 2004 04:31 | 4 |
var g:array[1..100,1..100] of boolean; d:array[1..100] of integer; v:array[1..100] of boolean; i,j,x,n,sum:integer; begin readln(n); fillchar(g,sizeof(g),false); fillchar(d,sizeof(d),0); for i:=1 to n do begin repeat read(x); if x=0 then break; g[i,x]:=true; inc(d[x]); until false; end; sum:=0; fillchar(v,sizeof(v),false); repeat for i:=1 to n do if (not v[i]) and (d[i]=0) then begin v[i]:=true; inc(sum); for j:=1 to n do if g[i,j] then dec(d[j]); if sum<n then write(i,' ') else writeln(i); end; until sum=n; end. What the hell are you doing here? You only need to sort the array and then output half of it. program ural1025; const maxk=101; var p:array[1..maxk]of integer; k,i,j:byte; t:integer; begin readln(k); for i:=1 to k do read(p[i]); for i:=1 to k-1 do for j:=i+1 to k do if p[i]>p[j] then begin t:=p[i];p[i]:=p[j];p[j]:=t; end; k:=k div 2+1;t:=0; for i:=1 to k do inc(t,p[k] div 2+1); writeln(t); end. |
How to get begin Data? | Para Zit | 1025. Democracy in Danger | 25 Nov 2001 15:33 | 2 |
Eng: What name of file with begin Data? Rus: Из какого,блин, файла надо брать исходные данные, или их надо получать с помощью Readln и выводить Writeln??? Eng: subj. Rus: Из стандартного, блин, ввода и вывода. :) |
Why this easy problem has such a long context,it cost me too much time to read,but only 2 mins to solve. :) | Huang Yizheng | 1025. Democracy in Danger | 13 May 2004 17:50 | 3 |
You are good now, you has improved a lot. |
Compilation Error ??? | Andrei Nikolov | 1025. Democracy in Danger | 20 Aug 2004 05:27 | 10 |
I recieve Compilation Error when submitting this code: (It compiles fine on my compiler)????? #include <iostream.h> int main() { int grupi[101] ; int k, num ; int sum=0 ; cin >> k ; for (int i=0; i<k; i++) { cin >> num ; if (num==0) grupi[i]=10000 ; else grupi[i]=num/2 + 1 ; } for (i=1; i<k; i++) for (int j=k-1; j>=i; j--) if (grupi[j-1] > grupi[j]) { int Temp=grupi[j-1]; grupi[j-1] = grupi[j] ; grupi[j] = Temp ; } for (i=0; i<(k/2+1); i++) sum+=grupi[i] ; cout << sum ; return 0 ; } > I recieve Compilation Error when submitting this code: (It > compiles fine on my compiler)????? > > #include <iostream.h> > > int main() { > int grupi[101] ; > int k, num ; > int sum=0 ; > > cin >> k ; > for (int i=0; i<k; i++) { > cin >> num ; > if (num==0) grupi[i]=10000 ; > else grupi[i]=num/2 + 1 ; > } > > for (i=1; i<k; i++) > for (int j=k-1; j>=i; j--) > if (grupi[j-1] > grupi[j]) { > int Temp=grupi[j-1]; > grupi[j-1] = grupi[j] ; > grupi[j] = Temp ; > } > > for (i=0; i<(k/2+1); i++) sum+=grupi[i] ; > cout << sum ; > return 0 ; > } > У тебя i объявлена внутри цикла, их компилятор это не понимает. Проси отсылать ответ на E-MAIL, там более подробная информация. Ok, which compilator the system uses? > > I recieve Compilation Error when submitting this code: > (It > > compiles fine on my compiler)????? > > > > #include <iostream.h> > > > > int main() { > > int grupi[101] ; > > int k, num ; > > int sum=0 ; > > > > cin >> k ; > > for (int i=0; i<k; i++) { > > cin >> num ; > > if (num==0) grupi[i]=10000 ; > > else grupi[i]=num/2 + 1 ; > > } > > > > for (i=1; i<k; i++) > > for (int j=k-1; j>=i; j--) > > if (grupi[j-1] > grupi[j]) { > > int Temp=grupi[j-1]; > > grupi[j-1] = grupi[j] ; > > grupi[j] = Temp ; > > } > > > > for (i=0; i<(k/2+1); i++) sum+=grupi[i] ; > > cout << sum ; > > return 0 ; > > } > > > У тебя i объявлена внутри цикла, их компилятор это не > понимает. Проси отсылать ответ на E-MAIL, там более > подробная информация. > Ok, which compilator the system uses? > May be gcc (GNU C Compiler (Linux)) > oh shit mine's the same #include <iostream.h> #include <stdlib.h> #define K 101 void main() { int group_num,person_num[K],temp,m,minimal_quantity=0; cin>>group_num; for(int i=0;i<group_num;i++) { cin>>person_num[i]; if(person_num[i]%2==0||person_num<1) exit(1); if(person_num[i]>10001) exit(1); } for(i=1;i<group_num;i++) for(int j=0;j<group_num-i;j++) if(person_num[j]>person_num[j+1]) { temp=person_num[j+1]; person_num[j+1]=person_num[j]; person_num[j]=temp; } for(i=0;i<=group_num/2;i++) { if(person_num[i]==1) m=1; else m=person_num[i]/2+1; minimal_quantity+=m; } cout<<minimal_quantity<<endl; } I have the same type of Error. I would post the source but under rules it says not to post source code. It compiles fine on my system and I use gcc that comes with MinGW. The most recent stable version so it should be up to date. Humm, that is very interesting. I got the error because I didn't add a newline character after the last line in my program. And I can't declear and array after the first "executable statement in block". Humm, I think they should update to a C99 standard compiler. Maybe instead of if(person_num[i]%2==0||person_num<1) you should write if(person_num[i]%2==0||person_num[i]<1) for (int j=k-1; j>=i; j--) - error!!! int j; for (j=k-1; j>=i; j--) - right!!! The library u`re using ... This is how it should be written : #include <iostream> using namespace std; int main() { int grupi[101] ; int k, num ; int sum=0 ; cin >> k ; for (int i=0; i<k; i++) { cin >> num ; if (num==0) grupi[i]=10000 ; else grupi[i]=num/2 + 1 ; } for (int i=1; i<k; i++) // int i ! for (int j=k-1; j>=i; j--) if (grupi[j-1] > grupi[j]) { int Temp=grupi[j-1]; grupi[j-1] = grupi[j] ; grupi[j] = Temp ; } for (int i=0; i<(k/2+1); i++) sum+=grupi[i] ; // int i ! cout << sum ; return 0 ; } |
Everything works fine, but still doesn't accept... | Maximka | 1025. Democracy in Danger | 6 Aug 2003 20:13 | 2 |
Any ideas why? #include <iostream.h> void main() { long int num, subnum[101], i, j, calc=0, temp, result=0; cin>>num; calc=num; for (i=0;i<num;i++) cin>>subnum[i]; if (num=1) cout<<(subnum[0]+1)/2; else for (i=num-1;i>0;i--) { for (j=num-1;j>num-i-1;j--) if (subnum[j]<subnum[j-1]) { temp=subnum[j-1]; subnum[j-1]=subnum[j]; subnum[j]=temp; }; calc--; result+=(subnum[num-i-1]+1)/2; if (calc*2<num) { cout<<result; break; } } } > Any ideas why? > > #include <iostream.h> > void main() > { > long int num, subnum[101], i, j, calc=0, temp, result=0; > cin>>num; > calc=num; > for (i=0;i<num;i++) cin>>subnum[i]; > if (num=1) > cout<<(subnum[0]+1)/2; > else > for (i=num-1;i>0;i--) { > for (j=num-1;j>num-i-1;j--) > if (subnum[j]<subnum[j-1]) { > temp=subnum[j-1]; > subnum[j-1]=subnum[j]; > subnum[j]=temp; > }; > calc--; > result+=(subnum[num-i-1]+1)/2; > if (calc*2<num) { > cout<<result; > break; > } > } > } > > |
Difficult !!!!!!! 8-> | Tran Nam Trung (trungduck@yahoo.com) | 1025. Democracy in Danger | 24 Mar 2001 16:22 | 4 |
This problem is more difficult to read than to do it. Do U think so ? > This problem is more difficult to read than to do it. Do U > think so ? |
TASK 1025 | Dennis S. Yolkin | 1025. Democracy in Danger | 30 Nov 2002 19:39 | 3 |
Чё за фигня!!! Вроде-бы таска - элементарная!!! А два Вронг Ансвера !!! I'm sorry. But having your very particular description of the problem you have I cannot help you. Could you write more exactly what is wrong? Or post you solution here. |