| Show all threads Hide all threads Show all messages Hide all messages |
| Tell me how solve this problem | Turdubek | 1113. Jeep | 27 Jan 2011 16:39 | 2 |
I advice you to read books of Martin Gardner. There is beautiful solution of this problem. Or you can write DP and look at the points where stations are built. |
| Test#7 | 我系花生我最捞 | 1098. Questions | 27 Jan 2011 12:31 | 1 |
Test#7 我系花生我最捞 27 Jan 2011 12:31 i've wa at Test#7 twice. At first,my program outputed "No comments.". Second,my program outputed "NO comments". |
| No subject | Redwan | 1001. Reverse Root | 27 Jan 2011 12:18 | 3 |
I have solved this problem but i am getting a problem about test case.I don't know when it will show it's output.I am giving input and input but when it will break to show output? Read FAQ Vladimir Yakovlev (USU) 3 Sep 2010 20:52 Eh... You can use "scanf()==EOF" or "(cin>>...)!=0", which may not work expectedly in your own machine. Edited by author 27.01.2011 12:26 |
| need help | misele | 1001. Reverse Root | 27 Jan 2011 12:10 | 2 |
someone help me, what's wrong with this code? #include <stdio.h> #include <math.h> int main(int argc, char **argv) { double nums[131072]; /* 256 * 1024 / 2 */ int count = 0; while (scanf("%lf", nums + count) != EOF) count++; while (count) { count--; printf("%.4lf\n", sqrt((double)(nums[count]))); } return 0; } AC! thanks no help needed anymore. Edited by author 02.11.2010 22:08 Isn't there any "Stack Overflow" error occured? And how can you terminate the input? I have tried "scanf(...)==EOF" and (cin>>...)!=0, but both failed. |
| Why do I get STACK OVERFLOW on test #6??? | Ruki | 1018. Binary Apple Tree | 27 Jan 2011 11:39 | 2 |
I just can not understand...... Edited by author 27.01.2011 11:40 I got it... The size of the edges is too small... It's RE... |
| What's the answer for n=6? | sillyboy | 1217. Unlucky Tickets | 27 Jan 2011 11:30 | 9 |
I minkerui 19 Nov 2002 18:11 > Who knows, who knows... > > Who knows, who knows... |
| If you have WA7 | Olzhas2dy | 1064. Binary Search | 27 Jan 2011 05:51 | 5 |
TEST: 9999 14 ANSWER: 1 10000 10000 |
| Why "Compilation error"? (C++) | Osanve | 1005. Stone Pile | 27 Jan 2011 04:49 | 1 |
My OS: Linux Ubuntu 10.10 I use gcc 4.4.5 (don't have OS Windows) On my computer no errors and warnings Program source: #include <iostream> #define abs(x) ((x)<0 ? -(x) : (x)) using namespace std; int main() { short n; long sum = 0; long firstSum = 0; long secondSum = 0; cin >> n; long w[n]; for(int i=0; i<n; i++) { cin >> w[i]; sum+=w[i]; } sum>>=1; long temp = w[0]; int num = 0; for(int i=0; i<n; i++) { if(temp<w[i]) { temp = w[i]; num = i; } } firstSum+=temp; w[num] = 0; for(int i=1; i<n; i++) { num = 0; while(w[num]==0) { num++; } temp = w[num]; for(int j=0; j<n; j++) { if((temp>w[j])&&(w[j]!=0)) { temp = w[j]; num = j; } } w[num] = 0; if(firstSum+temp<sum) { firstSum+=temp; } else { secondSum+=temp; } } cout << abs(firstSum-secondSum) << endl; return 0; } |
| Float number precision kills, use integer calculations will do | Neal Zane | 1679. Scrooge's Tower | 27 Jan 2011 02:09 | 8 |
A got AC using real numbers with EPS = 1e-8, so precision is not major matter here... i think it is safe to rotate point 1 90 degrees 4 times and check if it is possible to align the rotated point 1 with point 2 to form an edge of the square. rotated point1 will also have integer coordinates. Thanks, Neal Zane! Your idea is fruitful indeed. I've already gave up to overcome test#24, where float calculations seem to be very sensitive to precesion. And tan/atan along with sqrt gave me error of 10^-8. Now totally integer solution is concise and fast! Thanks for idea. Simple and beautiful. My previous AC solution was more difficult. I have tried this way. When I used the formula 2*(y0*x1 - y1*x0)^2 ? R^2*((x1 - x0)^2 + (y1 - y0)^2) (with 3 x <- -y, y <- x) (with long long on right side) has received WA 3. My previous right solution with use of floats has no more lines and operations. Therefore I believe that geometrical problems to solve in the habitual ways (via floats with epsilon) more preferably. It is necessary to use a "wheel", instead of to invent something new when good average speed of the decision of a problem is necessary. I was very surprised, when after WA1 and WA 2 my solution was accepted :) Pay attention to the situation, when points becomes the same. Pay attention to the situation, when points becomes the same. Thanks! Very useful hint! |
| What algorithm should you use? Random and nothing more... | Loky_Yuri [USTU] | 1103. Pencils and Circles | 27 Jan 2011 00:26 | 2 |
Yes, random work. My solution ~ 0.5s. Choose three random points and count points inside circle. Maybe weak tests... Edited by author 27.01.2011 00:28 |
| What algorithm is applicable for such problems? | Anupam Ghosh,Bengal Engg and Sc Uni,MtechIT,2006-09,India | 1324. Extra Spaces | 25 Jan 2011 20:42 | 2 |
Hi Experts, Can you suggest how to approach solving such problems. I am getting no clues at all. Moreover we know nothing about total number of spaces in the text. regards Anupam If you have a group with N spaces and apply to it the operation, that changes K spaces to one, then the number of spaces will be N/K + N%K. You should output such numbers K[1], K[2], ... , K[m], that for every number N in range [1..L] a sequence of operations N := (N/K[i] + N%K[i]) for each i = 1..m will make the value N equals 1. And then you should maximize the range for N. I guess it is a school problem :) Edited by author 25.01.2011 20:42 Edited by author 25.01.2011 20:43 |
| Help me | Turdubek | 1113. Jeep | 25 Jan 2011 19:21 | 1 |
Anyone help me to understand or solve this problem.I didn't understand how comes the answer 3837 |
| Changes in problem 1315 "MDPAR and MIIAR" (+) | Sandro (USU) | 1315. MDPAR and MIIAR | 25 Jan 2011 03:16 | 1 |
The limitations in the problem statement were decreased. New limitations are W, H ≤ 500; D ≤ 1000. Tests were fixed according to these limitations. New tests were added. All submits were rejudged. 5 submits got AC verdict, 41 submit lost AC verdict. Thanks to Sergey Vedernikov and Roman Rizvanov for new tests |
| No subject | Noob | 1021. Sacrament of the Sum | 25 Jan 2011 00:00 | 1 |
No subject Edited by author 25.01.2011 00:20 |
| WA5? | Timur Sitdikov (MSU TB) | 1201. Which Day Is It? | 24 Jan 2011 17:53 | 2 |
WA5? Timur Sitdikov (MSU TB) 24 Jan 2011 16:13 What is test 5? I can't find my mistake. Edited by author 24.01.2011 16:15 Edited by author 24.01.2011 16:15 Re: WA5? Timur Sitdikov (MSU TB) 24 Jan 2011 17:53 My code: #include <stdio.h> void printdw(int* f1, int *f3, int d, int dd, int lim) { int f2=0; if (d==1 || *f1==1) { if (dd==d) {printf(" [%2d]", d); f2=1;} else {printf(" %2d", d);} *f1=1; } else { if (dd==d) {printf(" [%2d]", d); f2=1; *f1=1;} else {printf(" %2d", d);} } for(d+=7; d<=lim; d+=7) { if (f2==1) {printf(" %2d", d); f2=0;} else { if(d==dd) {printf(" [%2d]", d); f2=1;} else printf(" %2d", d); } } if (d==lim+7) *f3=1; if(d<lim+7 && *f3) { if (!f2) printf(" "); else printf(" ");} printf("\n"); } int main() { int dd, mm, yy, dw, lim, f1, f2, f3, d; scanf("%d %d %d", &dd, &mm, &yy); dw=(6+yy-1600+((yy-1)/4-399)-((yy-1)/100-15)+((yy-1)/400-3))%7; if (mm==5) dw++; if (mm==8) dw+=2; if (mm==2 || mm==3 || mm==11) dw+=3; if (mm==6) dw+=4; if (mm==9 || mm==12) dw+=5; if (mm==4 || mm==7) dw+=6; if (mm>2) { if (!(yy%4)) dw++; if (!(yy%100)) dw--; if (!(yy%400)) dw++;} dw%=7; if (mm==1 || mm==3 || mm==5 || mm==7 || mm==8 || mm==10 || mm==12) lim=31; else { if (mm!=2) lim=30; else {if (yy%4 ||(!(yy%100) && yy%400)) lim=28; else lim=29;} } f1=0; f3=0; printf("mon"); d=(8-dw)%7+1; printdw(&f1, &f3, d, dd, lim); printf("tue"); d=(d+7)%7+1; printdw(&f1, &f3, d, dd, lim); printf("wed"); d=(d+7)%7+1; printdw(&f1, &f3, d, dd, lim); printf("thu"); d=(d+7)%7+1; printdw(&f1, &f3, d, dd, lim); printf("fri"); d=(d+7)%7+1; printdw(&f1, &f3, d, dd, lim); printf("sat"); d=(d+7)%7+1; printdw(&f1, &f3, d, dd, lim); printf("sun"); d=(d+7)%7+1; printdw(&f1, &f3, d, dd, lim); } Please! help to find mistake! Edited by author 24.01.2011 17:54 |
| SERUS EDDY | Micheal Jackson | 1215. Exactness of Projectile Hit | 24 Jan 2011 17:48 | 1 |
Ma prietenule! Ce mai faci? Vrei sa ma iubesti? |
| test this to check your program | stupidjohn | 1029. Ministry | 24 Jan 2011 13:11 | 1 |
|
| Test2 | Pavel | 1014. Product of Digits | 24 Jan 2011 10:59 | 1 |
Test2 Pavel 24 Jan 2011 10:59 Edited by author 24.01.2011 11:02 |
| WA test case 20 | HKMT | 1681. Brother Bear's Garden | 24 Jan 2011 10:45 | 1 |
Does any one know that case? Edited by author 24.01.2011 10:45 |
| remember to add 0 and 10^9 to your structure. | stupidjohn | 1019. Line Painting | 24 Jan 2011 09:26 | 1 |
|