| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| So, where the input stream ends ? | Black^n^White | 1001. Обратный корень | 2 янв 2008 01:11 | 10 |
As I understand the user can use new line to seperate the numbers, but how can we know which "Enter" is the last one (or the input stream ends) ? Thanks. Any examples for C# ? And example for Java, plz Read with Console.Read() char by char. When the end of input stream was reached method returns -1. Read with Console.Read() char by char. When the end of input stream was reached method returns -1. Will Reader.read() in Java have the same effect? Java : while((line = f.readLine()) != null) { ... } ?? I tried that and it didnt work... the program never stops... Does anybody know how to stop the infinite loop? Also, you can use Console.In.ReadToEnd(); |
| WHY TIme limit on 1 test????????????????????????????????? | Valera Darmakheev[Esstu] | 1027. Снова D++ | 1 янв 2008 22:00 | 2 |
WHY TIme limit on 1 test?????????????????????????? program z1027; {$APPTYPE CONSOLE} uses SysUtils; var s,s1:string; flag,flag1,i:integer; begin { TODO -oUser -cConsole Main : Insert code here } {$IFNDEF ONLINE_JUDGE} assign(input, 'input.txt'); reset(input); assign(output, 'output.txt'); rewrite(output); {$ENDIF} while not seekeof do Begin read(s1); s:=s+s1; End; ..... ..... {$IFNDEF ONLINE_JUDGE} close(input); close(output); {$ENDIF} end. Edited by author 01.03.2007 12:38 What does your code fragment mean? "Time Limit" error means that your algo use too much time. Try to find a better algo. P.S. Sorry for my English. |
| No subject | Alexandra | 1019. Перекрашивание прямой | 1 янв 2008 18:32 | 1 |
Edited by author 01.01.2008 18:34 |
| Help me please! WA 5 | Access Violation | 1026. Вопросы и ответы | 1 янв 2008 16:36 | 1 |
I have used quick sort algo, but I've got WA#5. Show me this test, please. I can't understand what mistake I've done in my solution. P.S. Sorry for my English. |
| Help JAVA solution | Frank Rodriguez | 1001. Обратный корень | 1 янв 2008 15:37 | 1 |
I can't seem to read the end of the input file, how can i fix this? This is my code: import java.io.*; import java.util.*; public class revroot {
public static void main(String[] args) {
Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out);
while (in.hasNextDouble()) { double a = in.nextDouble(); out.println(Math.sqrt(a)); } out.close(); } } Thanks in advance. |
| Happy New Year(-) | diver_ru (Fishburg SAAT) | | 1 янв 2008 03:00 | 1 |
|
| Java BigInteger was helpful for me!!! | manishmmulani | 1036. Счастливые билеты | 1 янв 2008 00:29 | 1 |
|
| I need some help plz HELP me! | Нищий Наглец | 1244. Джентльмены | 31 дек 2007 20:13 | 5 |
What output? 150 4 50 50 50 50 and this 200 4 50 50 50 50 My AC program outputs -1 in both cases Why output -1 for the second test??? My output for the first one is -1 and for the second one is an empty line. second test is not valid. it's given that some cards are missing... which means there is atleast one card missing |
| #1 OF 1083 | K-A-R-E-N | | 31 дек 2007 18:09 | 1 |
|
| About strategy | Брэнд | 1565. Необычная дуэль | 31 дек 2007 02:34 | 1 |
Please, explain, why a man with smallest precision must not shoot before killing one of others, and give me some examples for testing my program |
| TO ADMINS: Invalid Test #11 (-) | DixonD (Lviv NU) | 1373. Pictura ex Machina | 31 дек 2007 02:28 | 4 |
There are trailing spaces in some lines of input in test 11. Please, check this. Edited by author 25.12.2007 02:47 Please, give me answer, don't ignore my request...(( Now N <= 100000, Time Limit is 1 sec. All tests with trailing spaces are fixed. |
| random algorithm | lian lian | 1510. Порядок | 30 дек 2007 15:12 | 7 |
this is my code: #include<stdio.h> #include<stdlib.h> #include<math.h> int main() { long K[5000005],N,i,j,t,value,k,count,a,flag; scanf ("%ld",&N); if (N%2==0) k=N/2; else k=N/2+1; for (i=0;i<N;i++) scanf("%ld",&K[i]); for(i=0;i<N;i++){ j=rand()%N; for(flag=0,count=1,t=0;t<N;t++){ if (K[t]==K[j]) count++; if (count>=k){ value=K[j]; flag=1; break; } } if (flag=1) break; } printf("%ld\n",value); return 0; } why Crash (stack overflow)? please help me ? define big arrays outside procedures long K[5000005] I modify small than long K[5000005] to k[500005],but it Crash (stack overflow)? change you prog to -------------- long K[5000005] int main() { long N,i,j,t,value,k,count,a,flag; scanf ("%ld",&N); ------------ or use #pragma comment(linker, "/STACK:16777216") defaut stack size ~1mb Edited by author 29.12.2007 01:18 Thanks ( KIRILL(ArcSTUpid coder:) )to solve problem of memory for me,but now answer is wrong; could you mail to me for 1510?
email: k13795263@126.com thanks; The problem in rand(); See documentation for return value. It's too small. You need something like this: t = (rand()*rand())%N; |
| DP | svr | 1267. Екатеринбургское метро | 30 дек 2007 10:22 | 1 |
Excellent problem. Very realistic and DP works. Small advice: We should consider moments after stationary condition established: first trains went to last stations. Without this we must include 10^5 moments in Dp and will be MLE and TLE. Edited by author 30.12.2007 10:32 |
| What answer for n=2? | Ikari [pskov] - Andrey Marchenko | 1222. Chernobyl’ Eagles | 28 дек 2007 22:31 | 3 |
I think that correct answer for n=2 is 1, because if one of eagles has 2 heads and another 0 heads then IQ will be 2*0=0, isn't it? But my program had WA3 in that case. When I wrote 2 in output for n=2, I got accepted. Why? because you can have only ONE eagle with 2 heads in group, so IQ = 2. There was no obligations that group should consist of >=2 eagles... Edited by author 28.12.2007 21:55 Edited by author 28.12.2007 21:55 |
| I've got AC.Just try this testdata | lonelycorn | 1244. Джентльмены | 28 дек 2007 20:13 | 1 |
270 5 50 50 100 110 170 and the answer is -1 |
| could any C/C++ programmer solve this question?? | manishmmulani | 1017. Лестницы | 28 дек 2007 17:48 | 3 |
because... even the data type "long long" works only for numbers till 490 ... from 491 to 500... it gives wrong answer can any1 help please??
your solution is wrong besause answer always is less than 10^18 thanx a lot... i got my mistake |
| Sorting is the most sophisticated thing I've used to solve the problem (-) | Vedernikoff Sergey | 1499. Треуголки | 28 дек 2007 03:35 | 1 |
|
| why i got wrong 4? | shengxi4 | 1120. Сумма последовательных чисел | 27 дек 2007 22:10 | 4 |
#include<stdio.h> long n,a,k; void work () { long i,na,x; if (n<316227) x=2*n; else x=316227; for (i=x;i>=1;i--) { na=2*n+i-i*i; if (((na%(2*i))==0)&&(na>0)) { na=na/(2*i); a=na; k=i; break; } } } int main () { scanf ("%ld",&n); work (); printf ("%ld %ld",a,k); return 0; } Test: 10^9 Your program result: 4811 148480 My AC program result: 26263 25600 My program result: 1243 640 for n= 10^6 Edited by author 27.12.2007 22:11 #include<iostream> #include<stdio.h> using namespace std; __int64 n,a,k; void work () { __int64 i,na,x; if (n<316227) x=2*n; else x=316227; for (i=x;i>=1;i--) { na=2*n+i-i*i; if (((na%(2*i))==0)&&(na>0)) { na=na/(2*i); a=na; k=i; break; } } } int main () { cin>>n; work (); cout<<a<<" "<<k; return 0; } #include<stdio.h> long n,a,k; void work () { long i,na,x; if (n<316227) x=2*n; else x=316227; for (i=x;i>=1;i--) { na=2*n+i-i*i; if (((na%(2*i))==0)&&(na>0)) { na=na/(2*i); a=na; k=i; break; } } } int main () { scanf ("%ld",&n); work (); printf ("%ld %ld",a,k); return 0; } |
| WA on #14. | lonelycorn | 1039. Юбилейная вечеринка | 27 дек 2007 20:31 | 1 |
i've been making it for nearly a week and i still get WA on #14.who can tell me why,or give me the data? |
| Why I got wa on test#4? | panrui | 1588. Ямайка | 27 дек 2007 20:20 | 1 |
#include<iostream> #include<math.h> #define MAX 200000 #define N 350 using namespace std; int n; double map1[N][N]; struct node { int x,y; }point[N]; double dist(node a,node b) { return sqrt((double)((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y))); } void init() { cin>>n; int i,j; for(i=1;i<=n;i++) cin>>point[i].x>>point[i].y; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { map1[i][j]=dist(point[i],point[j]); //cout<<map1[i][j]<<" "; } //cout<<endl; } } double calck(node a,node b) { if(a.x-b.x!=0) return (a.y-b.y)/(a.x-b.x);else return -MAX; } int mid(node c,node a,node b) { if(a.x!=b.x) { if(abs(a.x-b.x)>abs(a.x-c.x)) return 1; }else if(abs(a.y-b.y)>abs(a.y-c.y)) return 1; return 0; } void solve() { int i,j,k,used[N][N]; double ans=0; for(i=1;i<=n;i++) for(j=1;j<=n;j++) { ans+=map1[i][j]; used[i][j]=0; } for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { for(k=1;k<=n;k++) { if(i==j || j==k || i==k) continue; if(calck(point[i],point[j])==calck(point[i],point[k]) && mid(point[k],point[i],point[j]) && used[i][k]==0 && used[k][i]==0) {ans-=map1[i][k]*2;used[i][k]=1;} } } } ans/=2; cout<<(int)(ans)<<endl; } int main() { init(); solve(); return 0; } |