|
|
Общий форумCan you send to me some test????????)) my idea: sum( (-1)^m * a^(n/(p[k1]*p[k2]*..*p[km] ) ) ), where p[i] - is prime number and n % p[i] == 0. also WA(4) why? 1. Q[k]-number for which k- minimal period 2 Q[k]=a^k-sum(Q[i],i<k k%i==0) 3. answer =Q[n]/n AC has. Big numbers rules from Test4. Learhed Python and taken Ac quickly Much more comfortable than java Edited by author 12.02.2018 11:13 There are __int128 and libquadmath with __float128 in GCC/clang. I sure there are problems, where these are sufficient to get AC. What do you think? [svr] solution (double for by K and I) with optimized long arithmetic by 10^9 base (9 digits packed in one int) in C++ can pass only by compiler choosing (got TLE 49 on Visual Studio and only g++ got AC), but solution uses 0.375 time and 63 Mb of memory - i.e. it is almost NOT a solution :)) So I can't imagine how to pass this on Python, which MUST be too slower than C++. Edited by author 30.12.2023 14:03 Domain and name must consist only of LOWERCASE letters and dots The length of each crystal's side is L, not one. 4 строки 274 байта кто короче? Unfortunately, I can't write the Python solution due to the rules, but it exists! Try to find it! input: -2 -2 2 -2 2 2 -2 2 0 2 1 0 -3 output: 7.236067977 input: 1 0 0 1 -1 0 0 -1 0 0 1 2 -1 output: 1.236067977 ... airplane must climb to an altitude of h meters during the first t seconds of the flight ... Can time be less than t when height h is attained ? Edited by author 18.12.2023 11:15 Edited by author 18.12.2023 11:15 1 2 3 1->2:180 180 -180 1->3:180 180 -180 2->3:180 180 -180 overall: 360 0 -360 prefix sum: 360 360 0 hence max from 1 to 3 is 360 do this similarly from 3 to 1 f(x) = (x-7)^2 + (x-4)^2 + (x-5)^2 Find x such that f(x) (cost function) is a minimum. df/dx = 2(x-7) + 2(x-4) + 2(x-5) = 0 3x = 7+4+5 x = (7+4+5)/3 The biggest hurdle is the problem statement itself! i think my algo is right but i have problem with overflow in C++. who can give me good test? PS: on Pypy i have TL50 using the same algo( And it's very strange because on test 1000000000 18 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 my algo works <300ms PS: AC in C++ after many hacking with overflow. I hate this problem because spent a lot of time to fix problem with arighmetic (not algo) Edited by author 12.12.2023 00:41 It seems that the worm always starts at back cover and ends at front cover and order of volumes matters. #include <iostream> using namespace std; int main() { double k; while(cin >> k) { cout << fixed << setprecision(4) << sqrt(k) << endl; } } I think the solution is supposed to start from the last number Подскажите, что нужно сделать чтобы у меня показывало на каком я месте в рейтинге? Просто интересно, уже год-два моя страничка вне рейтинга this is a not correct setting task, there are many solutions some of them is AC some of WA, but all of them are right for N this is a right solution count is 2*(N - 2) and 2 2 3 3 4 4 .... (N-1) (N-1) isn't it 1 10 1 2 -> 2: means books are placed upside down, in this case first sheet of the first book is adjacent to the second book 1 10 2 1 -> 22: means books are placed correctly, last sheet of the first book is adjacent to the second book Edited by author 10.11.2015 07:42 Try this test 1 100 4 1 1 2 1 3 1 4 1 1 2 3 4 0 0 0 1 5 1 Correct answer is: 3.0200000 4 1 2 3 4 #include<bits/stdc++.h> using namespace std; bool isPrime(int n) { if(n!=2&&n%2==0)return false; if(n<2)return false; for(int i=3;i<=sqrt(n);i+=2) { if(n%i==0)return false; } return true; } int main() { int n; cin>>n; int x=9,r; if(n==1)cout<<1<<endl; else if(n==0)cout<<10<<endl; else{ vector<int>v; while(1) { if(n%x==0) { if(isPrime(n)==true) { if(n>9){cout<<-1<<endl;return 0;} } n=n/x; if(x==1)break; v.push_back(x); } else { x--; } } for(int i=v.size()-1;i>=0;i--) { cout<<v[i]; } cout<<endl; } } For large N, 2% of sample are counted. |
|
|