Общий форумIs my greedy algo correct? On each step I choose an edge to vertex with the greatest out-degree. I have WA 8. Of course, you should find Euler cycle I know AC solution that counts number of cw and ccw moves from point i to i+1 seen from the first point. Here is the test on which this AC solution answers cw but correct answer is ccw. 17 0 0 10 0 10 10 11 10 11 9 11 8 11 7 11 6 11 5 11 4 11 3 11 2 11 1 11 0 12 0 12 11 0 11 I'm agree with you. Edited by author 22.03.2010 08:38 I'm sorry. I find my mistake/ I don't understand this problem. As I think, the third sample is the tree from the picture. But I can not understand why, for example, 'the number of the ancestor of this node' for the node #18 is 12? What does it mean, 'the number of the ancestor of this node'? THank you. As you can see in a picture, the node #18 connected with the #12 node, and - #18 is a child for #12; - #12 is a ancestor, farther (mother) of #18. In phrase "the number of the ancestor of this node" the word "number" should be understood ad index (the index of the node, which is an ancestor for target node). small a, big b, big n, and the LCM of a and b is larger than n. such as 3 24999998 25000000 Edited by author 21.03.2010 23:41 I have written 2 programs and both get WA19 It is very strange, I am already tired to write programs to this problem. first 2*BFS secondar Dijkvasta+Heap both got Wa19 i not understand why. Somebody help me? hi I don't understand in english. hwo can explain this question in Azeri or Turkish or in english but with sample sentenceses you just need to do 2 BFS Edited by author 22.03.2010 02:04 Edited by author 22.03.2010 02:04 there is my program var c:array[0..1800] of real; n,m,i ,fn:longint; begin readln(n,m); c[0]:=1; c[1]:=m-1; i:=1; repeat i:=i+1; {for i:=2 to n do } c[i]:=(m-1)*(c[i-1]+c[i-2]); until i>=n; writeln(c[n]:0:0); end. Because There is some testcases that have more than 1800 decimal digits.You should write Big int for this problem. My AC program runs about 10 seconds on following tests; 4 41 4 49 (on this test it works more, that 1 minute!!!) 17 43 19 49 41 43 50 41 50 43 I can write about 10 more tests, but, I think, it's enough:) Could you add some of these tests? Your tests were added, and problem was rejudged. Thank you. Here is my code, what can make my code run faster? Please check it up... #include <iostream> #include <cmath> using namespace std; bool prime(long long x) { int i;
if(x==2) return true; else if(x%2==0) return false;
for(i=3; i*i<=x; i+=2) if(x%i==0) return false; return true;
} int main() { long long K, s;
cin>>K; if(prime(K)==true) { cout<<K-1; return 0; } else { for(long long i=3; i<499999950; i++) { if(K%i==0) { cout<<i-1; return 0; } } } return 0; } Функция Prime может быть встроена в main Вместо if(Prime(K)==true) можно писать if(Prime(K)) oh my... =) This lazy code gets AC in 0.562s #include <cstdio> int n,r; int main() { .scanf("%d", &n); .r=2; .while ( n % (r+1) != 0 ) ..++r; .printf("%d",r); .return 0; } And this a little bit (only a little) improved, especially for you, gets AC in 0.296s. #include <cstdio> int n,r; int main() { .scanf("%d", &n); .if ( n % 3 == 0 ) .printf("2"); .else if ( n % 4 == 0 ) ..printf("3"); .else .{ ..r=4; ..while ( n % ++r != 0 ) ...++r; ..printf("%d",r-1); .} .return 0; } Hope this test can help you: 2 3 2 1 0 1 0 - NO YES Good luck! why my program doesnot work on WA#2???? var a:array [1..10000] of integer; i,k,s:integer; begin k:=0; s:=1; for i:=1 to 10 do readln(a[i]); for i:=1 to 10 do s:=s*a[i]; for i:=1 to s do if s mod i=0 then k:=k+1; if (k>0)and (k<10) then writeln(k); end. Edited by author 21.03.2010 05:16 I can't find a mistake in my solution. Can anybody give me any hint? #include <cstdlib> #include <iostream> #include <iomanip> using namespace std; int main(int argc, char *argv[]) {
double a,b,c,d,m,n=2,mn; cin>>a>>b; c=a/100; d=b/100; while (1) {m=1; while (m<n) {mn=m/n; if ((mn<d)&&(mn>c)) break; m++;} if (m!=n) break; n++;} cout<<n<<endl; system("PAUSE"); return EXIT_SUCCESS; } This is my project Got WA on test14. I think there's something wrong with digits But i cannot find it Can anyone help me with it? Thx! I think, your mistake in precision. Try change: if ((mn<d)&&(mn>c)) -> if ((mn+eps<d)&&(mn-eps>c)) I used "dp" and spend 261k space and 0.046 time, but i see the rank 1 only used 0.015 second?
How did he make it? Does it mean that we need to calculate the maximal displacement where the center goes even when it falls? And after the book starts falling must we consider that the book just rotates around the edge of the bookshelf? or it slides a little backwards. Some more explanation of the problem text and maybe some hints would be welcomed. Thank you. L.E. Now I get WA 8. I don't think there is a problem with precision, or something like that. Some more samples to pass this test? Does L have to be used at anything? I believe not since L>H. L.L.E. My WA 8 was from a division by 2 of an integer variable, which I assigned to a double variable. The problem was solved when I divided by 2.0 Edited by author 25.03.2010 20:20 #include<iostream> #include<algorithm> #include <list> #include <math.h> #include <iomanip> using namespace std; /*CODE*/ int main() { /*CODE*/ cout<<setprecision(9)<<fixed<</*CODE*/ <<sqrt(r2); return 0; } Using proprietary Intel compiler instead of free and de facto standard GCC is outrageous! I guess ФАС should investigate how this happened :-) What's wrong with the test 10? #include<stdio.h> int main(){ long unsigned int x,y=0,z=0,q,p,r; scanf("%lu",&r); x=r; q=r*r; do{ p=q-y*y; while( x*x >= p && x >= 0 )x--; z+=(x+1); y++; }while(y<r); z*=4; printf("%lu\n",z); return 0; } Используй long long и/или long double Submitting one problem I had a compilation error with making my own set comparator, although the program had succesfully been compiled by G++(GCC) 4.4.3 and Visual Studio 2008 compilers on my computer. By submitting some test programs I've found that the error is somehow related to the lower/upper_bound method of map and set containers. For instance, the code like this gets a compilation: #include <set> using namespace std; struct Less { bool operator()(pair <int,int> a, pair <int,int> b) { return a.first < b.first; } }; set <pair <int,int> , Less> s; set <pair <int,int>, Less>::iterator it; int main() { s.insert(make_pair(1,1)); it = s.lower_bound(make_pair(0,1)); return 0; }
The error message is following: 5bf1d001-ac4d-4354-a106-244d4befaf4e S:\checker\compile\\Vc7\include\xtree(988): error: no instance of function "Less::operator()" matches the argument list and object (the object has cv-qualifiers that prevent a match) argument types are: (const std::pair<int, int>, const std::_Tree<std::_Tset_traits<std::pair<int, int>, Less, std::allocator<std::pair<int, int>>, false>>::key_type) object type is: const Less if (this->comp(_Key(_Pnode), _Keyval)) ^ detected during: instantiation of "std::_Tree<_Traits>::_Nodeptr std::_Tree<_Traits>::_Lbound(const std::_Tree<_Traits>::key_type &) const [with _Traits=std::_Tset_traits<std::pair<int, int>, Less, std::allocator<std::pair<int, int>>, false>]" at line 801 instantiation of "std::_Tree<_Traits>::iterator std::_Tree<_Traits>::lower_bound(const std::_Tree<_Traits>::key_type &) [with _Traits=std::_Tset_traits<std::pair<int, int>, Less, std::allocator<std::pair<int, int>>, false>]" at line 21 of "5bf1d001-ac4d-4354-a106-244d4befaf4e" compilation aborted for 5bf1d001-ac4d-4354-a106-244d4befaf4e (code 2) So I think that it makes some STL features unavailable and wish it to be fixed. Does anybody know what can this test contain? I get WA every time I send my solution, can anybody give me some advice? If you need my code, you can connect me on the ICQ (425805594) |
|