Common BoardВ условии написано, что домино перевёрнута. Но я отыслал перевёрнутая версия - ошибка,  а не перевёрнутая версия принита, что за задача?   Edited by author 21.08.2012 15:51   Edited by author 21.08.2012 16:22 Pay attention that you should use LONGINT to avoid arithmetic overflow. maybe something like : 5 1 2 3 4 5     )))) i think that answer will be 16 ) i got 16, but it's again wa#2 ( Right answer is 13 I think you are wrong. My AC program prints 16 too   Edited by author 06.07.2011 11:00 plz some body explain with details plz.   Edited by author 20.08.2012 17:09   Edited by author 20.08.2012 17:09 #include <iostream>   using namespace std;   int main() {     int a[101];     int k;     cin>>k;     for (int i=0; i<k; i++)     {         cin>>a[i];     }     for (int i=0; i<k; i++)     {         int q=i;         int min=a[i];         for (int j=i+1; j<k; j++ )             if (a[j]<a[i])             {                 q=j;                 min=a[j];             }         if (q!=i)         {             int tmp=a[i];             a[i]=a[q];             a[q]=tmp;         }     }     long long s=0;     for (int i=0; i<=(k/2); i++)         s=s+((a[i]/2)+1);     cout<<s<<endl;     return 0; } Excuse me please, but I've already got AC. So I don't need your answers. plz explain what this test no shows ? type t=record      x:real;      y:real;      end; function arccos(a:real):real; var t:real; Begin if a=1 then arccos:=0 else if a=-1 then arccos:=180 else begin t:=a/sqrt(1-sqr(a)); arccos:=180*((pi/2)-arcTan(t))/pi; end; end;     function dlina(x1,y1,x2,y2:real): real; begin  dlina:=sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ); end;   function cos_(x1,y1,x2,y2,x3,y3:real):real; begin   cos_:=( dlina(x3,y3,x2,y2)*dlina(x3,y3,x2,y2) +  dlina(x1,y1,x2,y2)*dlina(x1,y1,x2,y2) -  dlina(x1,y1,x3,y3)*dlina(x1,y1,x3,y3)  ) /  2*dlina(x1,y1,x2,y2)*dlina(x3,y3,x2,y2);   end; var n,i:integer; x,y,p,cos,r:real; mas:array[1..102] of t; Begin readln(n,r); p:=0; for i:=1 to n do begin   readln(mas[i].x,mas[i].y);   if i>1 then p:=p+dlina(mas[i-1].x,mas[i-1].y,mas[i].x,mas[i].y); end;   p:=p+dlina(mas[1].x,mas[1].y,mas[n].x,mas[n].y);   mas[n+1]:=mas[1]; mas[n+2]:=mas[2];   for i:=1 to n do begin  cos:=-cos_(mas[i].x,mas[i].y,mas[i+1].x,mas[i+1].y,mas[i+2].x,mas[i+2].y);  p:=p+arccos(cos)*2*pi*r/360; end;   writeln(p:1:2); end.   Edited by author 21.03.2011 01:38 maybe you divide by zero.     Edited by author 18.08.2012 19:36 what is the test #7   Edited by author 18.08.2012 04:46 Some people claimed, that this problem can be solved in O(NlogN). How? My solution O(N^2) gets TLE #39...   Thanks in advance! use heap. What do you mean? Sort all starts/ends by angle. Then track closest inner wall within every angular segment, use heap for that. Comparing segments in a heap can be done by comparing distance to ray intersection. Though rays will be different during segment's lifetime, relative order of segments along the ray will not change because segments do not intersect. I've implemented this approach, but I have WA#33. I make exact calcucations except finding the square of triangle in the angular segment. Can somebody help me to overcome the problems with precision? Or maybe there's some bug in my program...   Edited by author 09.08.2009 21:21 Of course 2 segments compared once will never swap order; but suppose, there is an active segment in the heap whose end is not reached yet. However, another segment's start has come before in angle-wise sorted order. Now, when we enter that segment in the heap according to distance along current ray we have trouble; since, the previously mentioned segment's distance was calculated along old ray. Now, it may occur so that, the newly entered segment comes before along current ray, but previous segment might be popped before cause, its distance is less in heap - since, this is distance along old ray. And, there may be many such previous segments in the heap. I think, this gives same scenario as would be in case of intersection; and this is precisely what giving me WA 33. If, I update all existent segments in the heap by distance along current ray this gives the same effect as sorting edges each time and of course, gives me TLE 37 or 39. This is creeping me out. Sure, I am missing some trivial logic :(   Please, help me out.  Thanks in advance.   This is part of the code I am trying on now:     for(i=0;i<n;++i){         if(mark[arr[i].e1]) out(arr[i].e1);         else in(arr[i].e1,(arr[i].ang+arr[i+1].ang)/2.0);         if(mark[arr[i].e2]) out(arr[i].e2);         else in(arr[i].e2,(arr[i].ang+arr[i+1].ang)/2.0);         seg ret=heap_extract_max();         area+=triangle(make_pair(0.0,0.0),calc(ret.e,arr[i].ang),calc(ret.e,arr[i+1].ang));         in(ret.e,(arr[i+1].ang+arr[i+2].ang)/2.0);     } Sorry, I did stupid mistake. I made distance of a segment along some ray an attribute of the segment structure which is inserted on heap and in operator<() I compared that attribute. That's obviously wrong; since, newly inserted segment has distance calculated along different ray and can't be compared with others that way. But, look, 'the ORDER of the all previously entered segments' is correct. So, all i have to do is, rather than making distance an attribute, compute it along current ray/angle each time operator<() is called. I think, that will fix WA 33 of anyone getting it :) HI   I seem to be getting WA 5 everytime. Any ideas or hints on the test? Here is what i do: if start is 1 cout 1 for i=stop to start and for odd numbers     for j= 2 to floor(sqrt(i))         add the divisors     if it is a primeNumber cout<<i   cout the number with least triviality. in test5 I = J.   Try this 2 2   aswear 2.   Edited by author 17.08.2012 14:07 #include <stdio.h> unsigned long get_an(unsigned long n); int main(){     unsigned long n[10],i;     for(i=0; ; ++i){         scanf("%ld", &n[i]);         if(!n[i])             break;         n[i]=get_an(n[i]+n[i]%2-1);     }     for(i=0; n[i]; ++i)         printf("%ld\n", n[i]);     return 0; } unsigned long get_an(unsigned long n){     if(n==1)         return 1;     if(n%2)         return ( get_an((n-1)/2)+get_an((n-1)/2+1) );     else         return get_an(n/2); } I have WA #30, but on all tests and on same tests my solution give right answers. Can be there others tricks?  |  
  |