A-TT数鸭子
问题描述:
思路:
这道题用字符串来解答,计算每个中不同数字的个数若是超标则直接pass
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int A[10];
int main(int argc, char** argv)
{
int n,k,re=0;
long long int x;
cin>>n>>k;
for(int i=0;i<n;i++)
{
for(int k=0;k<10;k++)
{
A[k]=0;
}
int y=0;
scanf("%lld",&x);
while(x!=0)
{
A[x%10]++;
if(A[x%10]==1)y++;
x/=10;
if(y>=k)break;
}
if(y<k)re++;
}
printf("%d",re);
return 0;
}
B宇宙射线
问题描述:
思路:
这道题刚开始看错了,没有看见中心位于某个射线的起点上,当成了最小覆盖圆问题来解答,结果得了0分(惨痛的教训)
按照题意的话就直接枚举就行了
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int n;
long long int a,b,c;
struct node
{
long long int x,y,z;
bool operator <(const node &f)const
{
if(z!=f.z)return z<f.z;
else if(x!=f.x)return x<f.x;
else if(y!=f.y)return y<f.y;
}
}A[1005];
int main()
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>A[i].x>>A[i].y;
}
for(int i=0;i<n;i++)
{
a=0;
for(int k=0;k<n;k++)
{
b=pow((A[i].x-A[k].x),2);
c=pow((A[i].y-A[k].y),2);
a=max(a,b+c);
}
A[i].z=a;
}
sort(A,A+n);
printf("%lld.00 %lld.00\n%lld.00",A[0].x,A[0].y,A[0].z);
}
C宇宙狗的危机
问题描述:
思路:
这道题用到了区间dp,很难想到的,后来还是室友说可以用Dp来写,才反应过来
B[i][j]表示的时j的左孩子可以为区间[i,j],C表示的一样不过说的右孩子
然后枚举每一种情况确定是否成立
#include <iostream>
#include<string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int A[777],B[777][777],C[777][722],D[777][711];
int gg(int a,int b)
{
if(b==0)return a;
return gg(b,a%b);
}
int main(int argc, char** argv)
{
int l,n;
cin>>l;
while(l--)
{
bool ans=true;
cin>>n;
memset(B,0,sizeof(B));
memset(C,0,sizeof(C));
memset(D,0,sizeof(D));
for(int i=1;i<=n;i++)
{
cin>>A[i];
B[i][i]=C[i][i]=1;
}
for(int i=1;i<=n;i++)
{
for(int k=1;k<=n;k++)
{
D[i][k]=gg(A[i],A[k]);
}
}
for(int ll=n;ll>=1;ll--)
{
for(int r=ll;r<=n;r++)
{
for(int k=ll;k<=r;k++)
{
if(B[ll][k]&&C[k][r])
{
if(ll==1&&r==n)
{
ans=false;
}
if(D[ll-1][k]>1)
{
C[ll-1][r]=1;
}
if(D[k][r+1]>1)
{
B[ll][r+1]=1;
}
}
}
}
}
if(ans)cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
return 0;
}