A Audio
数论,三角形外心,三点到某点距离相等
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
double x[4],y[4];
for(int i=1;i<=3;i++)
cin>>x[i]>>y[i];
double A1,A2,B1,B2,C1,C2;
double x1,y1;
A1=2*(x[2]-x[1]);
B1=2*(y[2]-y[1]);
C1=x[2]*x[2]+y[2]*y[2]-x[1]*x[1]-y[1]*y[1];
A2=2*(x[3]-x[2]);
B2=2*(y[3]-y[2]);
C2=x[3]*x[3]+y[3]*y[3]-x[2]*x[2]-y[2]*y[2];
x1=((C1*B2)-(C2*B1))/((A1*B2)-(A2*B1));
y1=((A1*C2)-(A2*C1))/((A1*B2)-(A2*B1));
printf("%.3lf %.3lf\n",x1,y1);
}
B Bits
C Channels
模拟
#include<iostream>
#include<algorithm>
#include<math.h>
typedef long long ll;
using namespace std;
ll time(ll t)
{
ll m,h,res=0;
h=t/60;
m=t%60;
res=h*50;
if(m>=50)
res+=50;
else
res+=m;
return res;
}
int main()
{
ll t1,t2;
while(cin>>t1>>t2)
{
printf("%lld\n",time(t2)-time(t1-1));
}
}
D DDoS
E Exams
模拟
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=100;
double cj[maxn],bl[maxn],x[maxn];
int main()
{
int n;
cin>>n;
int cnt=0;
double zcj=0,zxf=0;
double flag,xf,pscj,psb,qz,qzb,qm,qmb;
for(int i=1;i<=n;i++)
{
scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&flag,&xf,&pscj,&psb,&qz,&qzb,&qm,&qmb);
if(flag==2)
continue;
else
{
cj[++cnt]=round(pscj*psb+qz*qzb+qm*qmb);
x[cnt]=xf;
zxf+=xf;
}
}
for(int i=1;i<=cnt;i++)
{
zcj+=cj[i]*x[i]/zxf;
}
printf("%.2lf\n",zcj);
}
F 进制转换
斐波那契规律题
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
string s;
int len;
cin>>s;
len=s.length();
if(s[len-1]%2==0)
cout<<"1"<<endl;
else
cout<<"-1"<<endl;
}
G Game
简单的素数判断和因数分解
#include<iostream>
#include<math.h>
using namespace std;
bool pri(int n)
{
if(n==1||n==2||n==3)
return 1;
if(n%6!=1&&n%6!=5)
return 0;
for(int i=5;i<=floor(sqrt(n));i+=6)
{
if(n%i==0||n%(i+2)==0)
return 0;
}
return 1;
}
int main()
{
int n;
cin>>n;
if(pri(n))
cout<<"Nancy"<<endl;
else
{
int cnt=0;
for(int i=2;i<=n;i++)
{
if(n%i==0)
{
while(n%i==0)
{
cnt++;
n/=i;
}
}
}
if(cnt%2!=0)
cout<<"Nancy"<<endl;
else
cout<<"Johnson"<<endl;
}
}
H ”Happy New Year!“
签到题
I I love you
子序列 dp题
#include<iostream>
#include<cstdio>
#include<math.h>
#include<cstring>
using namespace std;
const int mod=20010905;
int main()
{
int a,b,c,d,e,f,g,h;
a=b=c=d=e=f=g=h=0;
string s;
cin>>s;
for(int i=0;i<=s.length()-1;i++)
{
if(s[i]=='i'||s[i]=='I')
{
a++;
a%=mod;
continue;
}
if(s[i]=='l'||s[i]=='L')
{
b+=a;
b%=mod;
continue;
}
if(s[i]=='o'||s[i]=='O')
{
c+=b;
c%=mod;
}
if(s[i]=='V'||s[i]=='v')
{
d+=c;
d%=mod;
continue;
}
if(s[i]=='E'||s[i]=='e')
{
e+=d;
e%=mod;
continue;
}
if(s[i]=='Y'||s[i]=='y')
{
f+=e;
f%=mod;
continue;
}
if(s[i]=='O'||s[i]=='o')
{
g+=f;
g%=mod;
}
if(s[i]=='U'||s[i]=='u')
{
h+=g;
h%=mod;
continue;
}
}
cout<<h<<endl;
}
J Jelly
三维bfs
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<string>
#include<cstring>
#include<queue>
using namespace std;
const int maxn=1e2+5;
int n;
int dx[6]={0,1,0,-1,0,0};
int dy[6]={0,0,0,0,1,-1};
int dz[6]={1,0,-1,0,0,0};
char map[maxn][maxn][maxn];
int dis[maxn][maxn][maxn];
struct dian
{
int x,y,z;
};
bool pd(int x,int y,int z)
{
if(x>=1&&x<=n&&y>=1&&y<=n&&z>=1&&z<=n&&dis[x][y][z]==0&&map[x][y][z]!='*')
return true;
else
return false;
}
void bfs(int x,int y,int z)
{
queue<dian> q;
memset(dis,0,sizeof(dis));
q.push({x,y,z});
map[x][y][z]='*';
dis[x][y][z]=1;
while(q.size())
{
dian s=q.front();
q.pop();
for(int i=0;i<6;i++)
{
int nx=s.x+dx[i];
int ny=s.y+dy[i];
int nz=s.z+dz[i];
if(pd(nx,ny,nz))
{
dis[nx][ny][nz]=dis[s.x][s.y][s.z]+1;
q.push({nx,ny,nz});
}
}
}
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
for(int k=1;k<=n;k++)
{
cin>>map[i][j][k];
}
}
}
bfs(1,1,1);
if(dis[n][n][n]!=0)
cout<<dis[n][n][n]<<endl;
else
cout<<-1<<endl;
}