Codeforces 78D Archer ' s Shot

Source: Internet
Author: User

Two points.

Statistical processes such as:

Count the number on the red line first, then count the numbers on the green lines, and then count the number on the Brown line ... One by one you can jump down.

#pragmaComment (linker, "/stack:1024000000,1024000000")#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<vector>#include<map>#include<Set>#include<queue>#include<stack>#include<iostream>using namespaceStd;typedefLong LongLL;Const DoublePi=acos (-1.0), eps=1e-6;voidFile () {freopen ("D:\\in.txt","R", stdin); Freopen ("D:\\out.txt","W", stdout);} Template<classT>inlinevoidRead (T &x) {    Charc =GetChar (); X=0;  while(!isdigit (c)) C =GetChar ();  while(IsDigit (c)) {x = x *Ten+ C-'0'; c =GetChar ();}}DoubleR;DoubleSQRT3=SQRT (3.0);DoubleDisDoubleXDoubleY) {returnx*x+y*y;}BOOLCheckDoubleXDoubley) {    if(Dis (x,y+1)-eps>r*r)return 0; if(Dis (x,y-1)-eps>r*r)return 0; if(Dis (x+sqrt3/2, y+0.5)-eps>r*r)return 0; if(Dis (x+sqrt3/2, Y0.5)-eps>r*r)return 0; if(Dis (x-sqrt3/2, y+0.5)-eps>r*r)return 0; if(Dis (x-sqrt3/2, Y0.5)-eps>r*r)return 0; return 1;}intMain () { while(~SCANF ("%LF",&r)) {LL ans=0, l=1, R= (LL)2000000, POS;  while(l<=R) {LL mid= (l+r)/2; if(Check (mid-1) *sqrt3,0)) Pos=mid, l=mid+1; Elser=mid-1; } LL CNT=0;Doublex=0, y=-3;  while(1)        {            if(!check (x, y)) Break; LL L=1, R= (LL)2000000, pp;  while(l<=R) {LL mid= (l+r)/2; if(Check (x (mid-1) *sqrt3/2, Y (mid-1)*1.5)) Pp=mid, l=mid+1; Elser=mid-1; } pp=1+ (pp-1)*2, CNT=CNT+PP, y=y-3; } ans=6* (pos-1)+1+6*CNT; printf ("%lld\n", ans); }    return 0;}

Codeforces 78D Archer ' s Shot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.