## D1T1：math（小凯的疑惑）

30min之后用筛法水过去了：score=60；

```#include<iostream>
#include<fstream>
using namespace std;
int main(){
freopen("math.in","r",stdin);
freopen("math.out","w",stdout);
long long a,b;
cin>>a>>b;
cout<<a*b-a-b<<endl;
return 0;
}```

这里如果使用printf输出，要注意使用lld还是l64d。

## D1T2：complexity（时间复杂度）

```#include<iostream>
#include<fstream>
#include<cstring>
#include<cstdio>
using namespace std;
int s[101],t,l,top,maxn;
char h[101],k,b;
string x,y,a;
bool p,q;
int count1(){//提取复杂度数字
int x=0;
for (int i=4;i<a.length()-1;i++)
x*=10,x+=int(a[i]-48);
return x;
}
int count2(string a){//提取数值
int num=int(a[0]-48);
for (int i=1;i<a.length();i++)
num*=10,num+=int(a[i]-48);
return num;
}
bool work1(){
cin>>k>>x>>y;
h[++top]=k;
if (x=="n"){
if (y=="n") s[top]=1;
else s[top]=0;
}else{
if (y=="n") s[top]=2;
else{
int sx=count2(x),sy=count2(y);
s[top]=int(sx<=sy);
}
}
for (int i=1;i<top;i++)
if (k==h[i]) return false;
return true;
}
bool work2(){
if (top==0) return false;
int sum=0;
for (int i=1;i<=top;i++){
if (s[i]==0) break;
if (s[i]==2) sum++;
}
top--;
maxn=max(sum,maxn);
return true;
}
int main(){
freopen("complexity.in","r",stdin);
freopen("complexity.out","w",stdout);
cin>>t;
for (int m=1;m<=t;m++){
top=0,maxn=0,q=true;
cin>>l>>a;
int kind=(a[2]=='n')?count1():0;
for (int i=1;i<=l;i++){
cin>>b;
if (b=='F') p=work1();
else p=work2();
if (!p) q=false;
}
if (top!=0||!q) cout<<"ERR"<<endl;
else{
if (kind==maxn) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
return 0;
}```

## D2T1 cheese（奶酪）

```#include<iostream>
#include<fstream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int x[1001],y[1001],z[1001],kind[1001],q[1001];
bool v[1001],p;
int n,t,h,r;
double d(int i,int j){
double a=x[i]-x[j];
double b=y[i]-y[j];
double c=z[i]-z[j];
return sqrt(a*a+b*b+c*c);
}
void work(int k){
memset(kind,0,sizeof(kind));
memset(v,false,sizeof(v));
int l=1,rs=0;p=false;
scanf("%d%d%d",&n,&h,&r);
for (int i=1;i<=n;i++){
scanf("%d%d%d",&x[i],&y[i],&z[i]);
if (z[i]-r<=0) kind[i]+=2;
if (z[i]+r>=h) kind[i]+=1;
if (kind[i]>1) q[++rs]=i,v[i]=true;
}
while (l<=rs){
int x=q[l++];
if (kind[x]%2==1){
p=true;
break;
}
for (int i=1;i<=n;i++)
if (!v[i])
if (d(x,i)<=2*r) q[++rs]=i,v[i]=true;
}
if (p) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
int main()
{
scanf("%d",&t);
for (int it=1;it<=t;it++)
work(it);
return 0;
}```

```#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int q[1001],x[1001],y[1001],z[1001],k[1001];
int n,h,c;
bool v[1001];
double d(int i,int j){
double a=x[i]-x[j],b=y[i]-y[j],c=z[i]-z[j];
return sqrt(a*a+b*b+c*c);
}
int main(){
int t;scanf("%d",&t);
while (t--){
memset(v,0,sizeof(v));
memset(k,0,sizeof(k));
scanf("%d%d%d",&n,&h,&c);
int l=1,r=0;
for (int i=1;i<=n;i++){
scanf("%d%d%d",&x[i],&y[i],&z[i]);
if (z[i]<=c) k[i]++,q[++r]=i;
if (z[i]>=h-c) k[i]+=2;
}
bool flag=false;
while (l<=r){
if (k[q[l]]>1){flag=true;break;}
for (int i=1;i<=n;i++)
if (!v[i]&&d(q[l],i)<=2*c) q[++r]=i,v[i]=true;
l++;
}
if (flag) printf("Yes\n");
else printf("No\n");
}
return 0;
}```

## D2T2 treasure（宝藏）

```#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=15;
int n,m,x,y,u;
long long g[MAXN][MAXN];
long long f[MAXN][1<<12],d[MAXN][1<<12],D[1<<12][1<<12];
long long ans=0x7f7f7f7f,l;
int main(){
scanf("%d%d",&n,&m);u=(1<<n)-1;
memset(g,0x7f,sizeof(g));
memset(d,0x7f,sizeof(d));
for (int i=1;i<=m;i++){
scanf("%d%d%lld",&x,&y,&l);
g[x][y]=g[y][x]=min(g[y][x],l);
}
for (int i=1;i<=n;i++)
for (int s=0;s<(1<<n);s++)
for (int j=1;j<=n;j++)
if ((s>>(j-1))&1) d[i][s]=min(d[i][s],g[j][i]);
for (int s=0;s<(1<<n);s++)
for (int S=s^u;S;S=(S-1)&(s^u))
for (int i=1;i<=n;i++)
if ((S>>(i-1))&1){
if (d[i][s]==d[0][0]){D[s][S]=0;break;}
D[s][S]+=d[i][s];
}
for (int r=1;r<=n;r++){
memset(f,0x7f,sizeof(f));
f[1][1<<(r-1)]=0;
for (int i=2;i<=n;i++)
for (int s=0;s<(1<<n);s++)
for (int S=s^u;S;S=(S-1)&(s^u))
if (f[i-1][s]!=f[0][0]&&D[s][S]) f[i][s|S]=min(f[i][s|S],f[i-1][s]+D[s][S]*(i-1));
for (int i=1;i<=n;i++) ans=min(ans,f[i][(1<<n)-1]);
}
printf("%lld\n",ans);
return 0;
}```