牛客2021暑假多校训练营2
C | Draw Grids |
博弈论
可以发现,两人最后总是可以走n*m-1步,判断n*m-1的奇偶性即可,且样例比y较小,打表也可~
1 #include<bits/stdc++.h> 2 using namespace std; 3 int n,m; 4 int main() 5 { 6 cin>>n>>m; 7 n*=m; 8 n--; 9 if(n%2)puts("YES"); 10 else 11 puts("NO"); 12 return 0; 13 }
D | Er Ba Game |
签到题
1 #include<bits/stdc++.h> 2 using namespace std; 3 int T; 4 int a1,a2,b1,b2; 5 int main() 6 { 7 cin>>T; 8 while(T--) 9 { 10 cin>>a1>>b1>>a2>>b2; 11 if(a1>b1)swap(a1,b1); 12 if(a2>b2)swap(a2,b2); 13 if(a1==a2&&b1==b2)puts("tie"); 14 else if(a1==2&&b1==8)puts("first"); 15 else if(a2==2&&b2==8)puts("second"); 16 else if(a1==b1&&a2==b2)puts(a1>a2?"first":"second"); 17 else if(a1==b1)puts("first"); 18 else if(a2==b2)puts("second"); 19 else if(((a1+b1)%10)!=((a2+b2)%10))puts(((a1+b1)%10)>((a2+b2)%10)?"first":"second"); 20 else if(b1!=b2)puts(b1>b2?"first":"second"); 21 else 22 puts("tie"); 23 } 24 return 0; 25 }
F | Girlfriend |
高中数学
求两个球的交集体积,有模板:https://blog.csdn.net/luyehao1/article/details/86583384
#include <bits/stdc++.h> typedef long long ll; const long double pi = acos(-1); typedef struct { long double x, y, z, r; }Point; int n; Point other; Point s; //两点之间距离 long double dis(Point p, Point q) { long double ans = sqrt((p.x - q.x)*(p.x - q.x) + (p.y - q.y)*(p.y - q.y) + (p.z - q.z)*(p.z - q.z)); return ans; } long double x1,x2,yy1,y2,z1,z2,r1,r2,a[2],b[2],c[2],d[2],e[2],f[2]; long double k1,k2; long double pw(long double x){ return x*x; } long double calr(long double a,long double b, long double k){ return (-a*a+k*k*b*b)/(1-k*k) + pw((-k*k*b+a)/(1-pw(k))); } long double calpos( long double a,long double b, long double k){ return (a-pw(k)*b)/(1-pw(k)); } int main() { int T; scanf("%d", &T); while (T--) { for(int i=0;i<2;i++) scanf("%Lf%Lf%Lf%Lf%Lf%Lf",&a[i],&b[i],&c[i],&d[i],&e[i],&f[i]); scanf("%Lf%Lf",&k1,&k2); s.x=calpos(a[0],d[0],k1); s.y=calpos(b[0],e[0],k1); s.z=calpos(c[0],f[0],k1); long double r2 = calr(a[0],d[0],k1)+calr(b[0],e[0],k1)+calr(c[0],f[0],k1); s.r=sqrt(r2); other.x=calpos(a[1],d[1],k2); other.y=calpos(b[1],e[1],k2); other.z=calpos(c[1],f[1],k2); r2=calr(a[1],d[1],k2)+calr(b[1],e[1],k2)+calr(c[1],f[1],k2); other.r=sqrt(r2); long double ans = 0; long double d = dis(s, other); if(other.r>s.r) std::swap(other,s); if (d >= s.r + other.r) { }else if (d + other.r <= s.r) { ans += (4.0 / 3)*pi*other.r*other.r*other.r; } else { long double co = (s.r*s.r + d * d - other.r*other.r) / (2.0*d*s.r); long double h = s.r*(1 - co); ans += (1.0 / 3)*pi*(3.0*s.r - h)*h*h; co = (other.r*other.r + d * d - s.r*s.r) / (2.0*d*other.r); h = other.r*(1 - co); ans += (1.0 / 3)*pi*(3.0*other.r - h)*h*h; } printf("%.3Lf\n",ans); } return 0; }
I | Penguins |
经典bfs
有点长,先放着~
K | Stack |
****放着,大佬写的,还是看不懂,先把蓝书看完~