zoukankan      html  css  js  c++  java
  • 2019长沙学院暑假集训队第一次校赛A,B代码

    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
    ",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
    ",ans);
    64 
    65 }
    66 /*
    67 1 0 3 0 2 0 1
    68 0 0 4 0 2 0 1
    69 */
  • 相关阅读:
    phpMyAdmin出现错误 Access denied for user 'root'@'localhost' (using password: NO)
    Android使用butterknife注解出现nullPointerException解决
    Fragment Touch事件泄露
    清空Fragment回退栈中某个Fragment之上的所有Fragment
    Fragment保持状态切换
    点击EditText可编辑,点击其他地方不可编辑
    android ActionBar 去掉menu分隔线
    jquery validation remote进行唯一性验证时只使用自定义参数,不使用默认参数
    php 闭包函数
    phpstorm快捷按键
  • 原文地址:https://www.cnblogs.com/ccsu-kid/p/11253484.html
Copyright © 2011-2022 走看看