| Show all threads Hide all threads Show all messages Hide all messages |
| how read data? | tttwet | 1612. Tram Forum | 30 Jul 2010 13:17 | 2 |
hi guys how i must read string, using c# i mean read the WHOLE string, not just trim before '\n' sry for my language while((line=Console.ReadLine())!=null){ //..code here } |
| time-time-time... | azolotykh | 1100. Final Standings | 30 Jul 2010 11:24 | 2 |
that's simply funny - I got result in 1.046sec, but need 1sec... That's unfair.. Simply if you exceed TL, system kill your program and output time of execution of your program. That's why your time a little more than TL. Try to send program, which works infinitelly. |
| why, i get compile error | XMAN | 1150. Page Numbers | 30 Jul 2010 04:24 | 2 |
#include<conio.h> #include<math.h> #include<stdio.h> int k,t[10]; double fonction (int n, int i) { int h; if(n==1) { if(t[n]>=i) { return 1; } else { return 0; } } else { if(t[n]>i) { return ((pow(10,n-1))+(t[n]*pow(10,n-2))+(fonction(n-1,i))); } if(t[n]==i) { h=int(k/pow(10,n-1)); return (((k-(h*pow(10,n-1)))+1)+(t[n]*pow(10,n-2))+(fonction(n-1,i))); } if(t[n]<i) { return ((t[n]*pow(10,n-2))+(fonction(n-1,i))); } } } int main() { int n=0,i=1,j,m,r=1,w=0; scanf("%d",&k); m=k; // double q=1.56; while(m!=0) { n++; t[n]=m%10; m=m/10; //printf("%d",t[n]);
} for(i=0;i<n;i++) { w+=pow(10,i); } r=int(fonction(n,0)); printf("%d\n",r-w); for(i=1;i<10;i++) { r=int(fonction(n,i)); printf("%d\n",r); } getch();
return 0; } It's not allowed to use <conio.h> and getch(). Read FAQ. |
| How to realize long arithmetic in c++?(please, in example) | Cebiyev Ferhad | | 29 Jul 2010 23:06 | 3 |
Thank you. I think this will be helpful for me. |
| WA2 | remdy21 | 1077. Travelling Tours | 29 Jul 2010 19:59 | 1 |
WA2 remdy21 29 Jul 2010 19:59 why WA2?? program ural; var n,a,b,y:byte; m,i,z,r:integer; h,g:array[1..200]of integer; t:array[1..32767]of byte; l:array[1..32767]of integer; p,q:array[1..32767]of boolean; s:array[1..200]of byte; k:array[1..400]of integer; o:array[1..400]of byte; u:array[1..200]of boolean; x:boolean; procedure search(d:byte); var r:integer; begin u[d]:=true; r:=h[d]; while r<>0 do begin if u[t[r]]=false then begin inc(y); k[y]:=g[d]; g[d]:=y; o[y]:=t[r]; inc(y); k[y]:=g[t[r]]; g[t[r]]:=y; o[y]:=d; p[r]:=true; if q[r] then p[r+1]:=true else p[r-1]:=true; search(t[r]); end; r:=l[r]; end; end; procedure track(v,d:byte); var r:byte; begin if d=i then begin write(v,' '); for r:=1 to v-1 do write(s[r],' '); writeln(d); x:=true; exit; end; u[d]:=true; s[v]:=d; r:=g[d]; while r<>0 do begin if u[o[r]]=false then track(v+1,o[r]); if x then exit; r:=k[r]; end; end; begin assign(input,'travel.in'); assign(output,'travel.out'); reset(input); rewrite(output); readln(n,m); for i:=1 to m do begin readln(a,b); inc(r); l[r]:=h[a]; h[a]:=r; t[r]:=b; q[r]:=true; inc(r); l[r]:=h[b]; h[b]:=r; t[r]:=a; end; z:=m-n; for i:=1 to n do if u[i]=false then begin inc(z); search(i); end; if z<=0 then begin writeln(0); exit; end else writeln(z); for i:=1 to n do begin r:=h[i]; while r<>0 do begin if(q[r])and(p[r]=false)then begin x:=false; fillchar(u,sizeof(u),false); track(1,t[r]); end; r:=l[r]; end; end; end. |
| No subject | Narek X | 1008. Image Encoding | 29 Jul 2010 15:04 | 1 |
Edited by author 29.07.2010 21:50 |
| Help Please WA in test #3 | Deniska | 1008. Image Encoding | 28 Jul 2010 23:37 | 5 |
is there something tricky in it? I don't think so. Be careful. You must write 2 parts,from one to the another. I just use simple bfs ,then ac Edited by author 28.07.2010 23:39 T_T.......... I got AC; it's counterclockwise, so check the neighbors at the order R T L B install of R B L T. I hope it can save somebody some time. |
| I used set in my prog. againTLE 6???????????????????????? | Chelsea | | 28 Jul 2010 19:18 | 1 |
|
| if return 0 ? | svr | 1739. Faryuks | 28 Jul 2010 14:44 | 2 |
If we return 0 things must we write return 0 or return ? Also is not clear must we count returnings with 0 things? Not clear 3: Can we take bottle with each returning? Edited by author 11.11.2009 10:56 from statement: " if you want to return to the plantation s !>! 0". So, we mustn't output anything if we just return to the plantation with empty hands. |
| help! | chenxiang | 1068. Sum | 28 Jul 2010 12:44 | 4 |
help! chenxiang 25 Nov 2006 14:45 what is wrong with this code. #include<stdio.h> #include<stdlib.h> int main() { int n,i;long long int sum=0; scanf("%d",&n); if(n>=1) { for(i=1;i<=n;i++) sum=sum+i; } if(n<0) { for(;n<=1;n++) sum=sum+n; } printf("%ld \n",sum); system("pause");
} why i got wa? Re: help! <>|>|/|<|>>|<<>|-| 26 Nov 2006 08:16 if(n>0) { for(int i=1;i<=n;i++) sum=sum+i; } else { for(int j=n;j<=1;j++) sum=sum+j; } int main(int argc, char* argv[]) { int n,i,c; scanf("%d",&n); c=0; if (n>0) for (i=1;i<=n;i++) c=c+i; if (n<0) for (i=n;i<=1;i++) c=c+i; if (n==0) c=1; printf("%d",c); getch(); return 0; } |
| Java solutions | ile | 1100. Final Standings | 28 Jul 2010 05:17 | 2 |
Hey, I wonder what did people do in order to get less than 0.3s using Java? The minimum I got is only 0.343s 5590KB I use StreamTokeziner(BufferedReader) for input; PrintWriter for output; int[] ID, byte[] M, and O(n*m) outputing. I also tried to make it O(n) with LinkedList, but it didn't decrease time too much... Any suggestions to speed it up are welcome! =) |
| Fastest Java solution - 0.203s | void | 1100. Final Standings | 28 Jul 2010 05:16 | 1 |
First you should use BufferedReader for input and PrintWriter for output. Then you should create a big char[] buffer, read() whole input (3000000 chars is enough), manually parse it for data and put it into an array of some kind of Collections. While parsing you should calculate the length of output. Then you should create a char buffer of calculated size, manually fill it and print() whole buffer at once. If you still can't get the idea, write to Abrackadabraa@gmail.com. Java isn't slow, you just can't cook it. =) Edited by author 28.07.2010 05:20 |
| WA3 | rohit | 1572. Yekaterinozavodsk Great Well | 27 Jul 2010 23:02 | 3 |
WA3 rohit 16 May 2008 02:31 This is my code. #include<stdio.h> #include<math.h> double min(int t,int s) { switch (t) { case 1: return 2*s; case 2: return (double)s; default: return ((s/2)*sqrt(3.0)); } } double max(int t,int s) { switch (t) { case 1: return 2*s; case 2: return (s*sqrt(2.0)); default: return (double)s; } } void main() { int htype,hsize; int type,size; double max_len,min_len; int n,c=0; int i; scanf("%d %d",&htype,&hsize); max_len=max(htype,hsize); scanf("%d",&n); for (i=0;i<n;i++) { scanf("%d %d",&type,&size); min_len=min(type,size); if (min_len<=max_len) c++; } printf("%d",c); } Please tell me whats wrong.. Re: WA3 Smilodon_am 22 Oct 2009 13:50 Perhaps, the error is in the function "min". In case of triangle you return ((s/2)*sqrt(3.0)); But in C++ when "s" is "int" and "2" is "int", you will get not float division but only integer division. So when s==3, for example, ((s/2)*sqrt(3.0))==1*sqrt(3.0) You may write "s/2.0". Thanks..AC now. Such a silly mistake. |
| Wa at #38 | sweetsc | 1277. Cops and Thieves | 27 Jul 2010 21:25 | 3 |
why...... Edited by author 18.04.2008 21:42 Edited by author 18.04.2008 21:47 This test is something like: 1 1 0 1 1 1 the src and sink point are the same point.this is what #38 got. |
| This is a stupid question...!!! | Imran Yusubov | 1402. Cocktails | 27 Jul 2010 03:13 | 2 |
Dose anyone know a better solution?I used big Ints for this task.Do anyone has a mathematic solution? I have mathematic solution. a[i]=i*a[i-1]+i*(i-1); - it's true |
| Is x or y can be float? Or it is integer. | Cebiyev Ferhad | 1052. Rabbit Hunt | 26 Jul 2010 18:55 | 3 |
only integer @Точка задаётся целочисленными координатами x и y. @ Edited by author 26.07.2010 18:54 Edited by author 26.07.2010 19:44 |
| test#1 | ENick(TNU) | 1081. Binary Lexicographic Sequence | 26 Jul 2010 17:01 | 3 |
test#1 ENick(TNU) 28 Sep 2008 19:08 Please,take me a test#1.My program's output on example test are "000",but got WA#1 many times....((( Edited by author 28.09.2008 19:09 I think you forget this:"Write −1 if the number K is larger than the number of valid sequences" |
| How to count? | Pier Paolo Guillen Hernandez | 1142. Relations | 26 Jul 2010 16:31 | 4 |
Any hint on how to count all relations? Thanks! use DP. your function will be F(n, k) where N is the amount of number in the relation and K is the number of groups. For example: a=b=c=d - 1 group a=b<c=d - 2 groups a<b<c<d - 4 groups equal numbers form one group. Edited by author 09.05.2005 05:40 It's a maths problem. Like that puting N balls into M boxes. Edited by author 28.01.2008 07:01 Thank you! The idea of puting balls into boxes helped me. |
| How many tests this problem has? | 2rf [Perm School #9] | 1730. ManBearPig | 25 Jul 2010 23:41 | 2 |
Question in topic. I am wondering because my soution was testing for like 60 seconds, there were no other solutions in queue, and "execution time" was 0.031 seconds... cheсking answer takes a long time |
| Stuck on case #6!! Need some test case | #include <everything.h> | 1236. Decoding Task | 25 Jul 2010 22:51 | 6 |
I don't think there is something wrong, may be U just enlarge your array. here is test #6: 166DA60DB0D29CD2B6F51EEF245D027F0958F778E12533C7F2806E073724FE7B4E5F486B05D0F99E295B9B575AB37293A643219A228FDB8CD62B55F418586E1A2C58F3B410A8362B1BF594B20DE8628924DE63867948239A36F0159F6A217C1D6E692D97 0FDACE42A6B205B7AB71398E501C4F11FA389936B667EED607D681F1580487C95E96A93052AABE823C49DFE706DFD73A3248AF962A15DC868B5DF36A30C371B2896D26E04222E06C3FE2A8FA2E37178E8F6980DEC18D107AE09D902CEF73BCA79E5E25A221 Answer Seyyed Mehran Kholdi 23 Jan 2008 23:10 I think I know whats your problem (cause it was mine too) your first and second letter of output should be capital and the answer must be: 2FE340A40F0DDAF1884F8313AC9486951021E021EF69A24787A3A23D6251F2C5E038CEB68F204E3597F7730F5EDBBFF756B854E35364376A6DE63E01C51E37EB78394754A290D882966F325CC0FA05E9EFA2FC4106F2AAF38922427B0B128F54D7E7AB2492 printf with "%02X" instead of "%2X" |