Общий форумIn the statement it is said, that "If there are many such schemes, then you should choose an optimal scheme among them, i.e., a scheme that also reduces sequences of up to K spaces (K ≥ L) for a maximal possible K." So for the sample right answer would be 4 11 5 3 2 and maximum possible k = 110 Where I was wrong, people? :) Oh, now I see.. Admins, please correct russian statement. Look at this: English: If there are many such schemes, then you should choose an optimal scheme among them, i.e., a scheme that also reduces sequences of up to K spaces (K ≥ L) for a maximal possible K. If there are several optimal schemes, you may give any one of them. Russian: Если таких планов несколько, то вы должны выбрать среди них оптимальный — такой, который позволяет заменить последовательности пробелов длины K (K ≥ L) для максимально возможного K. These conditions are not equal! An example you can see in my previous post. Good Luck! I've just understood!! 1<=n<=1000 not n<=100 =))! Edited by author 28.01.2011 00:34 Explain please someone sample, coz I don't understand how can we get answer 0. My answer is 0.3660. I have the same trouble. But after some observings i found that i misunderstood statement. We need to find distance between resulting CENTER of the square and the given point. 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. i've wa at Test#7 twice. At first,my program outputed "No comments.". Second,my program outputed "NO comments". 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? 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 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. 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... > Who knows, who knows... > > Who knows, who knows... TEST: 9999 14 ANSWER: 1 10000 10000 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; } 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! 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 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 Anyone help me to understand or solve this problem.I didn't understand how comes the answer 3837 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 Edited by author 25.01.2011 00:20 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 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 Ma prietenule! Ce mai faci? Vrei sa ma iubesti? |
|