Show all threads Hide all threads Show all messages Hide all messages |
wrong with #8 | Liu Yizhou | 1013. K-based Numbers. Version 3 | 11 Sep 2007 23:31 | 2 |
Could anybody tell my what the test data#8 is, or tell me where my program wrong: var a,b,c:array [1..20000] of 0..9; n,k:longint; i,j:int64; procedure mul; var i,j,r,c:byte; begin c:=0; inc(j); while a[j]=0 do dec(j); i:=0; repeat inc(i); r:=a[i]*(k-1)+c; a[i]:=r mod 10; c:=r div 10; until i=(j+1); end; procedure add; var i,j,r,c:byte; begin c:=0; inc(j); while a[j]=0 do dec(j); i:=0; repeat inc(i); r:=a[i]+b[i]+c; a[i]:=r mod 10; c:=r div 10; until i=(j+1); end; begin read(n,k); fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0); fillchar(c,sizeof(c),0); a[1]:=k-1; j:=1793; i:=1; repeat inc(i); c:=a; add; mul; b:=c; until i=n; add; inc(j); while a[j]=0 do dec(j); inc(j); repeat dec(j); write(a[j]); until j=1; writeln; end. (like this one: var a,b,c:extended; n,k,i:integer; begin readln(n,k); a:=k-1; for i:=2 to n do begin c:=a; a:=(a+b)*(k-1); b:=c; end; a:=a+b; writeln(a); end.) [quote] procedure mul; var i,j,r,c:byte; begin c:=0; inc(j); while a[j]=0 do dec(j); i:=0; repeat inc(i); r:=a[i]*(k-1)+c; a[i]:=r mod 10; c:=r div 10; until i=(j+1); end; [/quote] r and others must not to be byte "r:=a[i]*(k-1)+c;" a[i]*(k-1)+c can be >255 use longint maybe Edited by author 11.09.2007 23:33 |
Check your tests! | FrancaiS | 1021. Sacrament of the Sum | 11 Sep 2007 20:02 | 1 |
This is my solution: Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n1 = in.nextInt(); int[] a = new int[n1]; for (int i = 0; i < n1; i++) a[i] = in.nextInt(); // Arrays.sort(a); int n2 = in.nextInt(); int[] b = new int[n2]; for (int i = 0; i < n2; i++) b[i] = in.nextInt(); // Arrays.sort(b); boolean res = false; for (int i = 0; i < n1; i++) if (Arrays.binarySearch(b, 10000 - a[i]) >= 0) res = true; if (res) out.println("YES"); else out.println("NO"); out.flush(); It have got WA on test#3 After uncommenting sorting I have got AC. But by the data I must not sort arrays, because its sorted. Am I wrong? Edited by author 11.09.2007 20:08 |
Very good problem | VC15 (Orel STU) | 1113. Jeep | 11 Sep 2007 02:48 | 2 |
I've spent so much time solving this problem and tried many different approaches. Finally, I've go Accepted. It's a very good problem, it develops your imagination. For those who doesn't no how to solve it there is a hint. Assume that N <= 4 / 3 * M and solve it. After that generalize your approach |
GIVE ME SOME TESTS!!! | ilovesky | 1021. Sacrament of the Sum | 10 Sep 2007 23:04 | 2 |
I have WA (test #5). Who can give me tests? I want to find and correct my mistake. Please, answer. |
why crash answer help me | aha | 1005. Stone Pile | 10 Sep 2007 13:21 | 1 |
hi , here is my code . why my program crashed.
/// code
import java.io.* ; import java.util.* ;
public class stonepile { public static void main(String args[]) throwsIOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str =null ;
while((str=br.readLine())!=null) { //str=br.readLine() ; StringTokenizer st = new StringTokenizer(str," ") ; String s = st.nextToken() ; int []a = new int [50] ; int []dp = new int [2000100] ; int sum= 0 ;
int n = Integer.parseInt(s) ; for ( int i = 0 ; i < n; i ++) { str = br.readLine() ; st = new StringTokenizer(str," "); s=st.nextToken() ; int m = Integer.parseInt(s) ; a[i] = m ; //sum +=m ; } dp[0] = 1 ; for ( int i = 0 ; i < n ; i++ ) { int c = a[i] ; sum+=c ; for ( int j = sum; j -c >= 0 ; j--) if ( dp[j-c]>0) dp[ j ] = 1 ; } int y = -1 ,x = -1, j= -1 , r = 20000000 ;
for ( int i = 1; i <sum+1 ; i++) if ( dp[i]>0 && dp[sum-i]>0) { x = Math.abs(i-(sum-i)); if ( r >x) r=x ; }
System.out.println(r) ; } }
}
|
Z_Function | Alias (Alexander Prudaev) | | 9 Sep 2007 16:37 | 1 |
Z_Function Alias (Alexander Prudaev) 9 Sep 2007 16:37 i have write my own Z function algorithm and need to test it please tell me some problems, where i need to use this function to solve it |
Бред | Krayev Alexey (PSU) | 1543. Dance Revolution | 8 Sep 2007 20:36 | 11 |
Бред Krayev Alexey (PSU) 30 Aug 2007 21:56 Зачем столько неясностей в условии оставлять, да ещё и, не скрывая этого, говорить "try both variants". А если не секрет, где здесь неясности? я их что-то не увидел... Re: Бред Krayev Alexey (PSU) 31 Aug 2007 01:57 Неясность в правилах вычисления Dance Level Bonus, совершенно непонятно, в каком их порядке применять. И как оказалось этот порядок отнюдь не от первого к последнему. Неясность какой промежуток времени считать бит-периодом. Какие границы включать в бит-период, а какие нет? Кстати в условии сказано, "A period between two consecutive beats is called a beat-period", т.е. границы не включая, на самом деле это не так. Edited by author 31.08.2007 01:58 Re: Бред Vedernikoff Sergey 31 Aug 2007 02:34 Statement + Sample give you clear undestanding of what you should do. At least, I accepted this problem during the contest... P.S. And Dance Level Bonus computing order is right - from first to last item. So, you should debug your program... Edited by author 31.08.2007 22:00 Я согласен с "Vedernikoff Sergey" по сэмплу можно все понять. Re: Бред Krayev Alexey (PSU) 31 Aug 2007 22:41 Я сдал эту задачу и порядок у меня там не от первого к последнему. Сэмпл не дает ответа на "граничные" вопросы, там можно менять уловия и ответ будет правильным. Edited by author 31.08.2007 22:43 Кто то может понять сэпл, кто то нет. А кому то просто повезло и он правильно интерпретировал то, что можно интерпретировать по разному. ИМХО В условии все долно быть написанно так чтобы понять по другому просто было не возможно. Re: Бред Vedernikoff Sergey 1 Sep 2007 02:35 I can give you source of my program. Order of processing of Dance Level Bonus there is from the first item to the last - and AC. So program that was written right according to the problem statement gets AC, and maybe other variants of wrong solutions get AC because of weak tests... Edited by author 01.09.2007 02:38 Re: Бред Krayev Alexey (PSU) 4 Sep 2007 22:13 Ну дай, посмотрю в каком у тебя там порядке проверяются... Кстати по поводу границ никаких замечаний не было, поэтому как минимум один косяк в тексте по любому есть. Edited by author 04.09.2007 22:14 Edited by author 04.09.2007 22:14 Re: Бред Vedernikoff Sergey 6 Sep 2007 21:03 Leave me your mail or send to sev [at] hotmail [dot] ru Re: Бред Vedernikoff Sergey 8 Sep 2007 20:36 As you can see, I'm right... |
OLE 11 help! | mj256 | 1092. Transversal | 7 Sep 2007 20:45 | 1 |
I use hungary algo, but OLE. It is right to use this algo? Or what should I improve in my prog? Any hint? Plz |
I dont know why!!! | visit.er | 1051. Simple Game on a Grid | 7 Sep 2007 19:24 | 1 |
It's easy to understand if (n mod 3=0) or (m mod 3=0) then answer=2 But why are the answers to the rest of datas are all 1???? Can someone tell me??? |
wa #15,I have been doing this problem the whole day.SOS | caobokai | 1019. Line Painting | 6 Sep 2007 17:30 | 1 |
|
Please give me some tests | Giorgi Saghinadze (Tbilisi SU) | 1437. Gasoline Station | 6 Sep 2007 17:20 | 3 |
I have WA6 Edited by author 18.09.2006 22:29 Edited by author 18.09.2006 22:29 For example: 1 100 255 result: 356 I have correct answer on this test, but WA#6( Please post tests or correct idea. |
Help!!Help!!Help me people of Earth.... | Chidori-kun | 1004. Sightseeing Trip | 4 Sep 2007 21:45 | 2 |
Can anybody give me good tests... My mistake was "Heap"..., not idea!!! |
Hints for those who got TLE~ | xcheng | 1055. Combinations | 4 Sep 2007 19:46 | 1 |
~.~ There is a trick in finding divsors. For example,the number of k divisor from 1~N is F(N)=N div k+N div (k*k)+N div (k*k*k)...... So we can just calc F(N)-F(M)-F(N-M) for every divisor that is between 1 and N. |
I think the sample must be wrong.My ac program output 'No comments' instead of 'Yes'! | aaakkk | 1098. Questions | 4 Sep 2007 17:49 | 5 |
My answer also as like as yours!!! Firsyt test must be "No comments" not "Yes" Isn't it? But My AC program gives Yes for first test. ID 1754502 |
Why WA#54???? | <-UnderFelixAbove-> | 1392. Dreaming of Stars | 4 Sep 2007 00:21 | 1 |
Hi,Gues! Please Help me! I have WA#54 and I don't understand what's wrong. This is my code #include <iostream> #include <algorithm> #include <string> #include <cmath> using namespace std; struct sphere { int x; int y; int z; int r; int num; bool met; sphere(){} sphere(int X,int Y,int Z,int R,int Num) { x = X; y = Y; z = Z; r = R; num = Num; met = false; } } mas[1005]; int x,y,z,r; int n; string STR[1005]; int countSTR; void input() { cin>>n; for (int i=0;i<n;i++) { cin>>x>>y>>z>>r; mas[i] = sphere(x,y,z,r,i); } } int posR; int posW; sphere Q[1005]; void Add(sphere sp) { Q[posW++] = sp; } void zero() { posR = 0; posW = 0; memset(Q,0,sizeof(Q)); } bool isInter(sphere &a,sphere &b) { int len = (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) + (a.z-b.z)*(a.z-b.z); int R = (a.r + b.r)*(a.r + b.r); if (len>=R) return false; return true; } void search(sphere sp) { zero(); sp.met = true; Add(sp);
while(posR<posW) { sphere cur = Q[posR++]; for (int i=0;i<n;i++) { if (mas[i].met == false) if (isInter(cur,mas[i])) { mas[i].met = true; Add(mas[i]); } } } int INT[1005]; int countINT = 0; memset(INT,0,sizeof(INT)); for (int i=0;i<posW;i++) { INT[countINT++] = Q[i].num; } sort(INT,INT+countINT); string str = ""; char tmp[10]; sprintf(tmp,"%i",INT[0]); str += tmp; for (int i=1;i<countINT;i++) { sprintf(tmp,"%i",INT[i]); str += ", "; str += tmp; } STR[countSTR++] = str; } void solve() { for (int i=0;i<n;i++) { if (mas[i].met==false) { mas[i].met = true; search(mas[i]); } } sort(STR,STR + countSTR); for (int i=0;i<countSTR;i++) { cout<<STR[i]<<endl; } } int main() { input(); solve(); return 0; } |
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 |
Help me, please! I've WA5! | Varduhy | 1104. Don’t Ask Woman about Her Age | 3 Sep 2007 22:03 | 3 |
Here is my solution! I can't find my mistake! Edited by author 03.09.2007 22:01 All ok with your code/ You must output "No solution." instead of "No solution" You forget point "." here. Edited by author 28.07.2007 20:38 Edited by author 28.07.2007 20:41 Thank you very much!!! :) |
WA on test 2 | Diduk Kirill | 1100. Final Standings | 3 Sep 2007 20:32 | 5 |
Can anybody help me with test 2? What is it? I use merge sort. I use qsort and have the same situation. You need to use stable sort. Bubble sort is stable nad qsort isn't. I used std::stable_sort() from C++ tempate library. Here also can be used linear radix stable sort or counting sort. i use counting sort, and got AC in 0.187s. =======core======= fillchar(c,sizeof(c),0); for i:=1 to n do inc(c[a[i].m]); for i:=99 downto 0 do inc(c[i],c[i+1]); for i:=n downto 1 do begin b[c[a[i].m]]:=a[i]; dec(c[a[i].m]) end; ================== I used merge sort and I've got AC. Use this test: 6 1 1 2 1 3 2 4 2 5 3 6 3 Right Answer is: 5 3 6 3 3 2 4 2 1 1 2 1 |
Please help me>I used priority__queue,but I kept on MLE#7.Why?Here is my code> | CHIDEMYAN SERGEY | 1306. Sequence Median | 3 Sep 2007 19:30 | 6 |
[code deleted] Edited by author 07.02.2008 01:45 [deleted] Edited by author 07.02.2008 01:45 Read first 3/4 of all numbers... Think some minutes. And then read remained 1/4. [code deleted] Edited by author 07.02.2008 01:45 |
WA #5 | Machvi | 1512. Zinium | 3 Sep 2007 17:45 | 2 |
WA #5 Machvi 18 Mar 2007 03:57 can somebody tell what is the 5th test? |