|
|
Common Board2^19 or another where factorized number = 19 IF you have TL, try this test: 18 aasda0sd basdasdasd casdasd asdasd33a 0b12asdasd ca45sdasd cdasdas3das dasd0asda2ds e1dasqew sdsdad4asdsaf dasda0sdasd 0gasdasd asdasda5sa asdasdasd3b asda0sdasdc aqwewq6e bqweqwe cqweq0we cqweqw7e dqweqwe eqw3ewqees fsadasd8asd dasdasdas0d gasdasd asdasds9adasa abasdas3dads casdasd12 qweqwew123qea bqweqw3ewqe cweqqwee csadas12d dasdas0d ed0dsdadsa fdasdasd33 dasdasds30ad gasasdsad adasdasd123d badas3ddasda cdasds0adas asdads455as basdasda2sd casdasdd0sa cqwewq123e deeqw12e eqw1easda8d fasd123asd dasdasds3a1dqw gqwe9wqewes jeqweqw123e eqweq123wewee hwewe9wqq ldszczx123c ad123sdasdaq qweweq09f ans: 18 Edited by author 10.08.2019 22:28 Edited by author 10.08.2019 22:28 Edited by author 10.08.2019 22:28 #include<bits/stdc++.h> using namespace std; int main() { double a,b,c,d,m,n,l,p,t,s,k; cin>>a>>b>>c>>d>>m>>n>>l; p=sqrt((a-m)*(a-m)+(b-n)*(b-n)); t=sqrt((c-m)*(c-m)+(d-n)*(d-n)); s=max(p,t); if(s>l){s-=l; } else{ s=0;} k=min(p,t); if(k<=l){ k=0; } else if(p==t){ a=(a+c)/2,b=(b+d)/2; k=sqrt((a-m)*(a-m)+(b-n)*(b-n)); if(k<=l){ k=0; } else{ k-=l; } } else{ while(abs(p-t)>.001){ if(p<t){ c=(a+c)/2,d=(b+d)/2; t=sqrt((c-m)*(c-m)+(d-n)*(d-n)); } else{ a=(a+c)/2,b=(b+d)/2; p=sqrt((a-m)*(a-m)+(b-n)*(b-n)); } } k=min(p,t); if(k<=l){ k=0; } else{ k-=l; } } cout<<fixed<<setprecision(2)<<k<<endl; cout<<fixed<<setprecision(2)<<s<<endl; } There seems to be some junk at the end of test 27. My solution with "while (read()) solve();" got WA but when I removed it I got OK. Test was fixed. Thank you! Методы Программирования и Прикладные Алгоритмы My solution is O(n) (<=60 * n iterations) but I have TL on python Help me to read fast data input My input code: n, l, r = map(int, input().split()) tokens = sys.stdin.read().split() a = list(map(int, tokens)) Thx But I solved problem using C++. The same algo but new implementation (added if ((prod / (double)1000000000) * a[j-1]> 1000000000) j = 0; else prod *= a[j-1];) Edited by author 07.08.2019 13:55 I used some methods, got TLE || WA ...T T ... You can enumerate P . Think carefully and you will get a O(sqrt(n)) solution. Spend some time for enum, cause i don't wanna to calculate in float variables. So fun!) #include<bits/stdc++.h> using namespace std; int main(){ unsigned long long int n; try{ cin >> n; cout << n%7 << endl; }catch(exception e){ cout << 1 << endl; } return 0; } Some have claimed that this is a very difficult problem. Not true! There is a reasonably simple and very fast DP-solution to this problem. No string algorithms are required beyond the naive ones that every non-programmer knows. Hint: Store the solution for sentences of length k in A[k], and store the number of strings that end with some forbidden word i (0 < i < P), but does not contain any other forbidden words as substrings in F[i][k]. Then construct the solution from A[k] to A[k+1], updating F[i][k+1] as well for each i. For each new character that you tuck onto the end of a valid string of length k, you get A[k] more valid strings, except those that end with a forbidden word, so those strings need to be removed. But make sure you don't remove stuff that you've assumed that you already removed earlier in the string - that's where F[i][k] comes in handy. every body handshakes all else his couple so n*(n-1) div 2 - k (couples doesnt handshake eachother)! --> Var n,k:integer; begin readln(n,k); writeln(((n*(n-1)) div 2) -k); end. Aidin_n7 What is The Autor Thinking? What's the meaning of the spliting group numbers? It just piss me off. Yep, this is the one way for solution. I've met problem like that earlier. Statements consist kinda "you need to get very-very much operation with binary code of number", but after some tests we understood, that solution was kinda "ans = n*(-1)". And it's good to have a short cut in problems for clever men;) This is my solution O(M log N) #include <bits/stdc++.h> #define in(x) freopen(x,"r",stdin) #define out(x) freopen(x,"w",stdout) #define N 100500 #define oo ll(1e16) #define P pair < int, int > #define PP pair < pair < int, int >, int > #define F first #define S second #define pb push_back #define el endl #define base ll(1e9 + 7) using namespace std; typedef long long ll; typedef long double ld; int n, m, y; bool o; int bin(int x, int st) { int res = 1; for(; st > 0;) { if (st & 1) res = (res * x) % m; x = (x * x) % m; st >>= 1; } return res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> y; o = 0; for (int i = 1; i < m; i++) { int cur = bin(i, n); if (cur == y) cout << i << ' ', o = 1; } if (!o) cout << -1; } Test: 123131 Answer: 123321 Thanks! Didn't make numbers equal to zero in encreasing numbers after the right one of comparing; Use scanline y = -x + a We need to use no more than 6 points If you want to be fast use k-statistic in O(n) For better explanation write here: myironmistake@gmail.com Edited by author 06.08.2019 18:42 Even though it took me almost 2 hours to solve I'm surprised this has difficulty of 1539. It doesn't require any special knowledge and almost anyone can solve this. Solution is pretty straightforward. Anyone can give me this test case? DELETED Edited by author 04.08.2019 22:55 Dear admin: Please add this test: 3 2 4 6 2 1 7 8 I got tle on this test.But fortunately I got AC! My AC solution outputs "YES" on that test case. 3 5 1 4 5 7 3 8 2 4 4 7 5 3 7 7 0 3 5 2 5 1 5 3 4 3 8 8 8 6 0 6 6 1 I got tle on these tests.But I got AC. My AC solution outputs "NO" on both of those test cases. My two AC submissions give different answers on this test: 3 4 0 0 0 0 6 1 5 5 2 8 5 3 P.S. The first test case isn't the sample. Edited by author 19.11.2013 01:26 My AC solution outputs "NO" on that test case. |
|
|