码迷,mamicode.com
首页 > 其他好文 > 详细

2019长沙学院暑假集训队第一次校赛A,B代码

时间:2019-07-27 00:11:34      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:cos   int   end   can   tor   amp   using   ble   bit   

A

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 __int128 gcd(__int128 x,__int128 y){
 5     return x%y==0?y:gcd(y,x%y);
 6 }
 7 int main(){
 8     ll x,y,z;
 9     cin>>x>>y>>z;
10     __int128 g1=gcd(x,y);
11     __int128 k=x*y;
12     k/=g1;
13     __int128 g2=gcd(k,z);
14     __int128 h=k*z;
15     h/=g2;
16     ll ans=h/x+h/y+h/z;
17     cout<<ans<<endl;
18     return 0;
19 }
20 /*
21 99999997 99999998 99999999
22 */

 

 

B

 1 #define bug(x) cout<<#x<<" is "<<x<<endl;
 2 #include<bits/stdc++.h>
 3 using namespace std;
 4 const double Pi=acos(-1);
 5 const double eps=1e-10;
 6 struct Point{
 7     double x,y;
 8     Point(double x=0,double y=0):x(x),y(y){};
 9 };
10 typedef Point Vector;
11 Vector operator +(Vector A,Vector B){return Vector(A.x+B.x,A.y+B.y);}
12 Vector operator -(Vector A,Vector B){return Vector(A.x-B.x,A.y-B.y);}
13 Vector operator *(Vector A,double B){return Vector(A.x*B,A.y*B);}
14 Vector operator /(Vector A,double B){return Vector(A.x/B,A.y/B);}
15 int dcmp(double x){
16     if(fabs(x)<eps)return 0;
17     return x<0?-1:1;
18 }
19 bool operator<(const Point&a,const Point&b){return a.x<b.x||(a.x==b.x&&a.y<b.y);}
20 bool operator == (const Point &a,const Point &b){return dcmp(a.x-b.x)==0&&dcmp(a.y-b.y)==0;}
21 void Correct(double &A){
22     while(dcmp(A)<0)A+=Pi;
23     while(dcmp(A-Pi)>=0)A-=Pi;
24 }
25 double Dot(Vector A,Vector B){return A.x*B.x+A.y*B.y;}
26 double Length(Vector A){return sqrt(Dot(A,A));}
27 double Cross(Vector A,Vector B){return A.x*B.y-A.y*B.x;}
28 void readp(Point &A){
29     scanf("%lf%lf",&A.x,&A.y);
30 }
31 double dis(Point P,Point A,Point B){//点到线段的距离
32     if(A==B)return Length(P-A);
33     Vector v1=B-A,v2=P-A,v3=P-B;
34     if(dcmp(Dot(v1,v2))<0)return Length(v2);
35     else if(dcmp(Dot(v1,v3)>0))return Length(v3);
36     else return fabs(Cross(v1,v2))/Length(v1);
37 }
38 //double ax,ay,bx,by,cx,cy,r;
39 double r;
40 Point A,B,C;
41 int main(){
42     readp(A);
43     readp(B);
44     readp(C);
45     cin>>r;
46     Vector AB=B-A;
47     Vector AC=C-A;
48     Vector CB=B-C;
49     double h=dis(C,A,B);
50     if(h>=r){
51         printf("%.10lf\n",Length(AB));
52         return 0;
53     }
54     double a=Length(CB);
55     double c=Length(AB);
56     double b=Length(AC);
57     double k1=acos((a*a+b*b-c*c)/(2*a*b));
58     double k2=acos(r/b);
59     double k3=acos(r/a);
60 
61     k1=k1-k2-k3;
62     double ans=b*sin(k2)+a*sin(k3)+r*k1;
63     printf("%.10lf\n",ans);
64 
65 }
66 /*
67 1 0 3 0 2 0 1
68 0 0 4 0 2 0 1
69 */

 

2019长沙学院暑假集训队第一次校赛A,B代码

标签:cos   int   end   can   tor   amp   using   ble   bit   

原文地址:https://www.cnblogs.com/ccsu-kid/p/11253484.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!