Общий форумI test the 13th case which has been given before but it gives WA for test 13. please can any body tell me what's the wrong Show me test 13 please. #include <cstdio> #include <cmath> #include <algorithm> struct point { int x, y; }; double distance(const point P1, const point P2) { return sqrt((double)(P1.x - P2.x)*(P1.x - P2.x) + (double)(P1.y - P2.y)*(P1.y - P2.y)); } bool operator ==(const point P1, const point P2) { if (P1.x == P2.x && P1.y == P2.y) return 1; return 0; } int main() { point A, B, C; unsigned int L; scanf("%d%d%d%d%d%d%d", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y, &L); const double pi = 3.14159265; const double epsilon = 0.00000001; double alpha, beta, gamma; double a, b, c; a = distance(B, C); b = distance(A, C); c = distance(A, B); alpha = acos((b*b + c*c - a*a)/(2*b*c)); beta = acos((a*a + c*c - b*b)/(2*a*c)); gamma = acos((a*a + b*b - c*c)/(2*a*b)); if (A == B) { printf("1 is working\n"); printf("a is %.2lf\nb is %.2lf\nc is %.2lf\n", a , b , c); printf("alpha is %.2lf\nbeta is %.2lf\ngamma is %.2lf\n", alpha, beta, gamma); if (L >= a) printf("0.00\n0.00\n"); else printf("%.2lf\n%.2lf\n", a - L, b - L); return 0; } if(abs(alpha + beta - pi) < epsilon) { printf("2 is working\n"); printf("a is %.2lf\nb is %.2lf\nc is %.2lf\n", a , b , c); printf("alpha is %.2lf\nbeta is %.2lf\ngamma is %.2lf\n", alpha, beta, gamma); double nl1 = std::min(a, b); double nl2 = std::max(a, b); if (L >= nl1) printf("0.00\n"); else printf("%.2lf\n", nl1 - L); if (L >= nl2) printf("0.00\n"); else printf("%.2lf\n", nl2 - L); return 0; } if (abs(alpha - pi/2) < epsilon) { printf("3 is working\n"); printf("a is %.2lf\nb is %.2lf\nc is %.2lf\n", a , b , c); printf("alpha is %.2lf\nbeta is %.2lf\ngamma is %.2lf\n", alpha, beta, gamma); double nl1 = b; double nl2 = std::max(a, b); if (L >= nl1) printf("0.00\n"); else printf("%.2lf\n", nl1 - L); if (L >= nl2) printf("0.00\n"); else printf("%.2lf\n", nl2 - L); return 0; } if (abs(beta - pi/2) < epsilon) { printf("4 is working\n"); printf("a is %.2lf\nb is %.2lf\nc is %.2lf\n", a , b , c); printf("alpha is %.2lf\nbeta is %.2lf\ngamma is %.2lf\n", alpha, beta, gamma); double nl1 = a; double nl2 = std::max(a, b); if (L >= nl1) printf("0.00\n"); else printf("%.2lf\n", nl1 - L); if (L >= nl2) printf("0.00\n"); else printf("%.2lf\n", nl2 - L); return 0; } if(alpha > pi/2) { printf("5 is working\n"); printf("a is %.2lf\nb is %.2lf\nc is %.2lf\n", a , b , c); printf("alpha is %.2lf\nbeta is %.2lf\ngamma is %.2lf\n", alpha, beta, gamma); double nl1 = b; double nl2 = a; if (L >= nl1) printf("0.00\n"); else printf("%.2lf\n", nl1 - L); if (L >= nl2) printf("0.00\n"); else printf("%.2lf\n", nl2 - L); return 0; } if(beta > pi/2) { printf("6 is working\n"); printf("a is %.2lf\nb is %.2lf\nc is %.2lf\n", a , b , c); printf("alpha is %.2lf\nbeta is %.2lf\ngamma is %.2lf\n", alpha, beta, gamma); double nl1 = a; double nl2 = b; if (L >= nl1) printf("0.00\n"); else printf("%.2lf\n", nl1 - L); if (L >= nl2) printf("0.00\n"); else printf("%.2lf\n", nl2 - L); return 0; } printf("7 is working\n"); printf("a is %.2lf\nb is %.2lf\nc is %.2lf\n", a , b , c); printf("alpha is %.2lf\nbeta is %.2lf\ngamma is %.2lf\n", alpha, beta, gamma); double nl1 = b * sin(alpha); double nl2 = std::max(a, b); if (L >= nl1) printf("0.00\n"); else printf("%.2lf\n", nl1 - L); if (L >= nl2) printf("0.00\n"); else printf("%.2lf\n", nl2 - L); return 0; } Check this situations: A = B, B = C, A = C Because, if you are calculating angle between vectors with formula: cos a = (scalar mult) / (|len1| * |len2|), so if one of distance is 0 - you will get "nan" (Not A Number) = something / 0 ... Edited by author 09.11.2013 13:43 I have solved this problem by Fenvic tree, at first I got WA on 5 test, then I changed int-s into long long-s and now I have WA on 6 test. If you had this kind of experience please tell me what types should I use to get AC? Thanks. The test 6 aint about data types' ranges. იდეაში, ეგ ხო ფენვიკის ხით უნდა გავიდეს, მე ვთვლი რაოდენობას, რამდენი გაყიდვა შესრულდება და შემდეგ ვამრავლებ 0.01–ზე და ვაბეჭდინებ. და ეგრე უნდა მუშაობდეს წესით ხო? Try this test BID 0.01 SALE 0.02 10 Answer:0.00 Maybe! test 1 is n=4 test 3 is n=2 var n,i : word; p : real; function check(A : real):boolean; begin if frac((1+sqrt(8*A-7))/2) = 0.0 then check := true else check:=false; end; begin readln(n); for i:=1 to n do begin readln(p); if check(p) then write('1 ') else write('0 '); end; end. Yes, because the difference of correct answer (when you use -1) and your is 2, so there is no difference to use +1 or -1! )))) frac((1+sqrt(8*A-7))/2) Where from it formula? What means? Could you take a look at my c++ code? I did the same as you but i never pass test #3 !! #include <iostream> #include <cmath> bool isOne (long n) { double intPart; double para = (1 + sqrt ( 8 * n -7)) / 2; double fractPart = modf(para, &intPart); if (fractPart == 0.0) return true; else return false; } int main() { using namespace std; long value; long num, i = 0; cin >> num; while (i < num) { cin >> value; if (isOne (value)) cout << "1 "; else cout << "0 "; i++; } return 0; } It solved my problem 0 1 1 1 0 after this test i pass 9 test and get ac 3 5 -1 4 -1 answear: 4 Edited by author 08.11.2013 21:24 Found. If someone will have the same issue, try this input: 3 Isenbaev A B A B C A Q W Edited by author 25.01.2013 23:37 Edited by author 25.01.2013 23:37 A 1 B 1 C 2 Isenbaev 0 Q 2 W 2 But i still #WA7 #include <iostream> using namespace std; int main() {int N,sum=0; cin>>N; if(N<0 && abs(N)<=10000) { for (int i=N; i<=1; i++) sum+=i;} else if (N>0 && abs(N)<=10000) { for(int i=1; i<=N; i++) {sum+=i;} } cout<<sum<<endl; system("pause"); } При N=0 сумма будет равна 1, у тебя это не выполняется. Просто введи дополнительное условие на это значение. Can anyone provide a sample for test 3? Thanks. 1 1 Your result should be 1 but I think your program will output 0 That was the problem in my case I use the dp to solve this problem. but always wa #2. who can help me? where i need to pay attention? Yes, it is the dp. I also get wa #2, but in my case WA means runtime error. After fixing this bug(IndexOutOfRangeException) i get AC. if there is a test like this "5 100 w" does it mean that both points 5 and 10 are colored in white? or only points betwen them. can somebody give me test, I have WA 9 TRY to test this cases: INPUT 2 5 100 w 10 10 b OUTPUT 0 1000000000 INPUT 14 1 999999999 b 1 300 b 20 120 w 1 50 b 220 300 w 250 270 b 40 70 w 50 160 b 30 90 w 120 140 w 40 50 b 180 200 w 1 40 w 70 80 w OUTPUT 0 40 INPUT 9 2 34 w 1 95 b 33 875 b 34 543 w 33 762 b 98754 999999843 b 87 221 w 76 432 w 325 764 b OUTPUT 875 98754 Edited by author 01.01.2009 12:08 thank you very much! but test#1 can never happy,because:0 < ai < bi < 109 resolved Edited by author 08.11.2013 09:29 Edited by author 08.11.2013 09:29 Edited by author 23.11.2013 14:14 Edited by author 07.11.2013 19:12 #include <iostream> using namespace std; int step(long int mas[],int n) { int i; int sum=0; for(i=n;i<n+3;i++) sum=sum+mas[i]; return sum; } int main() { int n,i; long int res; long int mas[1000]; cin >> n; for(i=0;i<1001;i++) mas[i]=0; for(i=0;i<n;i++) cin >> mas[i]; int sum=step(mas,0); res=0; for(i=0;i<n-2;i++) if(step(mas,i)<step(mas,i+1)) { sum=step(mas,i+1); res=i+3; } cout << sum << " " << res; return 0; } some tests, that could help you 1 0 0 anwear: * 3 0 0 0 5 5 0 answear: *..... |..... |..... |..... |..... *----* 3 0 1 0 5 0 9 answear: * | | | * | | | * + Hi, your checker doesn't check that exactly M lines are printed. My submission #5318694 has received AC. That's OK. In this problem you may output numbers with any whitespaces between them. If all the numbers are right, your solution will be accepted. Can someone give me an input example with the right output so I could check it, 'cause all the test I run are right i use binsearch and have wa 15.. i found this test 1 1 5 1 2 what's answer? is this test correct? My AC solution replies 1. I don't know if this test is correct as I solved this problem loooong ago. this test is incorrect because answer for it is -(1/3), it's not integer number 1st elem - 1 2nd elem - -1/3 3rd elem - 2/3 4th elem - 1/3 5th elem - 1 Edited by author 01.11.2008 04:06 i use binsearch and have wa 15.. any hints plz About this test {1 1 5 1 2} case the answer is also 0. The sequence is {1 0 1 0 1} Edited by author 01.04.2011 15:39 It's wrong. If f[2]=0, the sequence is {1 0 1 1 2}. How to avoid WA 15 While calculating f[n] during another iteration of binary search, every time check if f[i] is out of [-2*10^9, 2*10^9]. If it is, immediately break calculation cycle, update binary search interval and start another its iteration. I used formula and a C++ type long long, but still somehow managed to get WA 15. Even though i got around it by calculating in Zp (where p is a prime number bigger than 4 * 10^9), it still blows up my mind how it's possible to overflow long long without violating the statement. Such a tricky test, i'd like to see it. Some tests: test: -36 1680987685 37 1439530908 1 ans: 12 test: 42 1330344015 -38 -1330344015 30 ans: 4131543 test: -459 0 245 0 999 ans: 0 Edited by author 05.11.2013 18:43 Edited by author 05.11.2013 18:47 |
|