|
|
Common BoardThe only formulas you need is a distance between two points to find the answer and a distance between point and a line to check if answer exists For every pair of points, build circles on them and find their collision points(<= 2). Then for every collision point find number of points on distance < r to it. Maximum is the answer #include <stdio.h> int main() { int t1,t2,n; int c=0; scanf("%d %d", &t1, &t2); for (int i=0; i<=9; i++) { scanf("%d", &n); c+=(n*20); } t2-=c; if (t2<t1) { printf("Dirty debug :("); } else { printf("No chance."); } } Если я не ошибаюсь, вам стоит подключить пространство имён. using namespace std; Any help? In WA5 X=Y and thus the answer should be "0" If you have WA 13, try this test: 1 a 1 b....ba , where b repeated ~130000 times If you've got rte 27: m can be more than 10000 With help of my friend that was just looking at maximums index sequense and found an idea, finally, I got AC. Some hints: 1) Find an idea to calculate next maximum indices from previous ones: all the maximum's indices can be obtained from previous ones in such ways: i = s*2 + 1; or i = s*2 - 1; or i = s*4 + 1; or i = s*4 - 1; for example f(21)=8 is maximum for 21<=n<=34 so 21 = 2*11-1, where 11 is one of previous maximums indices. And so on using all the formulas above. but 2*11+1 = 23 is not a maximum index. so we have to cancel this number (23). 2) Learn to calculate f(n) in O(logn) 3) Generate all maximums indices (about 1500). You can store them in heap to get an access to the smallest maximum index. 4) than read n and just search for it in maximums index array. P.S. who can prove the first and the main idea? If you can, please post here you proof. How did you invent it? Edited by author 05.07.2009 22:51 It seems that only test s*2 - 1 and s*4 - 1 is OK. I've tested by bruteforce program in range [0, 20000000]. I will try it. Edited by author 15.10.2016 08:24 This is exactly how my accepted program runs. Suppose i is a maximum index, i = 2*i1+1, i2 = i1+1, then either 1) i1 is even, at least one of i1/2, i2 is a maximum index; or 2) i2 is even, at least one of i2/2, i1 is a maximum index. But I don't know how to prove it. Thus candidate indices from 2^n to 2^{n+1} can be generated from calculated maximum indices from 2^{n-2} to 2^n. You only have four things to pick from, so you can calculate each step explicitly. This equation follows the notation in the article: T is the time to collect all of the items, and ti be the time to collect the i-th item after i−1 items have been collected. E(T)=E(t1)+E(t2)+E(t3)+E(t4)=p1−1+p2−1+p3−1+p4−1. The probability p1 of picking a new one if you have picked none yet is 1. The probability p2 of picking a new one if you have picked one depends on which one you picked first. Let's call the items A through D and the probabilities of picking each item if they're all in the box pa through pd. Then p2 would be pa(pb+pc+pd)+pb(pc+pd+pa)+pc(pd+pa+pb)+pd(pa+pb+pc). The above expression is the probability of picking a new one given that A had been picked already, plus the probability of picking a new one given that B had been picked already, and so on. The expression for p3 will have six terms in the sum; one of these will be papb(pc+pd). The expression for p4 will have four terms in the sum (actually, it's the same term four times!) What can I do?.. My program passes all testes here, but still WA12... Any test cases? it takes a lot of my times. #include<iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << b-1 << ' ' << a - 1; } 4 2 2 3 2 1 3 3 1 2 4 1 3 6 5 2 3 4 5 6 5 1 3 4 5 6 5 1 2 4 5 6 5 1 2 3 5 6 5 1 2 3 4 6 5 1 2 3 4 5 8 7 2 3 4 5 6 7 8 7 1 3 4 5 6 7 8 7 1 2 4 5 6 7 8 7 1 2 3 5 6 7 8 7 1 2 3 4 6 7 8 7 1 2 3 4 5 7 8 7 1 2 3 4 5 6 8 7 1 2 3 4 5 6 7 6 2 2 3 2 1 3 2 1 2 2 5 6 2 4 6 2 4 5 diameter of 6875 miles (/ 2 = 3437.5)??? the mean radius of earth is 6371.0 km (3958.8 miles) a = input() minussum=0 plussum=0 b =[0:3] c =[3:6] c=int(c) minus = c-1 plus = c+1 minus=str(minus) plus=str(plus) for i in minus: i=int(i) minussum+=i for i in plus: i=int(i) plussum+=i n=0 for i in b: i=int(i) n+=i if n == minussum or n == plussum: print("Yes") else: print("No")
Help please) Why re? Edited by author 13.09.2022 23:21 Python files encoded in UTF-8 with BOM always get "Runtime Error 1". It would be nice if it was fixed. I just do maxsimum 30 iteration on my super all doing bruteforce and this give me right ans and i got ac I could solve it using trivial bruteforce. But I get TL, using more clever and probably expected solution. I used this: https://e-maxx.ru/algo/discrete_root (Read only first section, we don't need anything else). The slowest part here is Discrete Logarithm, which I calculate in \sqrt{n} * log_from_map. My program stuck at WA-17 for several times and I don't know the reason why. Can anyone give me some challenging test cases? Update: accepted now. Key point is to run unit test for the integral division function that I wrote. Both self-written complex division and std::complex<long double> division can be used to get approximate value of the quotient. The more - the better! 'cause I have no idea what I'm doing wrong :\ 50 49 8.4 5.5 //1 50 49 8.4 5 //25 50 49 8.4 4 //28 50 49 8.4 2.0 //37 50 49 8.4 0.2 //48 The answer of second test case is 1, not 25. My ac programm gives 1 for second and 25 for third test #include <iostream> using namespace std; int main() { int leavingCars, minutes; int carPerMinute[100]; int totalCars = 0;
cin >> leavingCars >> minutes; int carsLeavingPerMinute = leavingCars * minutes;
for(int index = 1; index <= minutes; ++index) { cin >> carPerMinute[index]; totalCars += carPerMinute[index]; }
cout << totalCars - carsLeavingPerMinute;
return 0; } |
|
|