欢乐纪中某B组赛【2018.12.22】

版权声明:原创,未经作者允许禁止转载 https://blog.csdn.net/Mr_wuyongcong/article/details/85208822

前言

全暴力第9了解一下,


成绩

R a n k Rank 是有算别人的

R a n k Rank P e r s o n Person S c o r e Score A A B B C C
9 9 2017 m y s e l f 2017myself 71.4 71.4 36.4 36.4 30 30 5 5
9 9 2017 x x y 2017xxy 71.4 71.4 36.4 36.4 30 30 5 5
11 11 2017 z y c 2017zyc 66.4 66.4 36.4 36.4 30 30 0 0
13 13 2017 l r z 2017lrz 56.4 56.4 36.4 36.4 20 20 0 0
14 14 2017 h z b 2017hzb 46.4 46.4 36.4 36.4 10 10 0 0
19 19 2017 l w 2017lw 10 10 0 0 10 10 0 0
23 23 2017 x j q 2017xjq 0 0 0 0 0 0 0 0
23 23 2017 h j q 2017hjq 0 0 0 0 0 0 0 0

正题


T 1 : j z o j 2700 T1:jzoj2700- 数字【数论 , L C M ,LCM

数论神题
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/85207199


T 2 : j z o j 3511 c z a T2:jzoj3511-cza 的蛋糕【状态压缩 d p , d f s dp,dfs

状压神题
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/85207614


T 3 : j z o j 3519 T3:jzoj3519- 灵能矩阵【 L C M , LCM, 树形 d p dp

怎么这么多LCM
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/85208305


s o m e   o f   c o d e some\ of\ code


T1 36.4分code

#include<cstdio>
using namespace std;
int n,f[1000000];
int D(int x)
{
	if(x<10) return x;
	int sum=0;
	while(x) sum+=x%10,x/=10;
	return D(sum);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=1000000;i++)
	{
		for(int j=1;j<=9;j++)
		    if(D(i/j)==j&&i%j==0){
		    	f[i]=1;
		    	break;
			}
		f[i]+=f[i-1];
	}
	while(n--)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%d\n",f[r]-f[l-1]);
	}
}

T2 30分code

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#define N 75
#define MS 138
using namespace std;
int a[N][N],ans,n,m;
bool check()
{
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=m;j++)
	    if(a[i][j]&&(a[i+1][j]||a[i][j+1])) return false;
	return true;
}
void dfs(int x,int y,int c)
{
	int mx,my;
	if(c==ans) return;
	if(x==n&&y==m&&check())
	{
	    ans=c;
	    return;
	}
	else if(x==n&&y==m) return;
	if(x==n) mx=1,my=y+1;
	else mx=x+1,my=y;
	dfs(mx,my,c);
	if(!a[x][y])
		return;
	if(a[x+1][y]){
		a[x+1][y]=0;
		a[x][y]=0;
		dfs(mx,my,c+1);
		a[x+1][y]=1;
		a[x][y]=1;
	}
	if(a[x][y+1]){
		a[x][y+1]=0;
		a[x][y]=0;
		dfs(mx,my,c+1);
		a[x][y+1]=1;
		a[x][y]=1;
	}
}
int main()
{
	freopen("cake.in","r",stdin);
	freopen("cake.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=m;j++)
	  {
		char c;
		cin>>c;
		a[i][j]=(c=='.');
	  }
	ans=2147483647;
	dfs(1,1,0);
	printf("%d",min(ans,max(n,m)));
}

T3 5分code

#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int N=100010;
vector<int> a[N];
int n,x,y,w[N],ans;
bool cmp(int x,int y)
{return w[x]<w[y];}
void dp(int x)
{
	if(!a[x].size()) return;
	for(int i=0;i<a[x].size();i++)
	  dp(a[x][i]);
	sort(a[x].begin(),a[x].end(),cmp);
	int sw=w[a[x][0]];
	for(int i=1;i<a[x].size();i++)
	{
		int y=a[x][i];
		ans+=w[y]-sw;
	}
	w[x]=sw*a[x].size();
}
int main()
{
	freopen("pylon.in","r",stdin);
	freopen("pylon.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	  scanf("%d",&w[i]);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
	}
	dp(1);
	printf("%d",ans);
}

尾声

暴力出奇迹

猜你喜欢

转载自blog.csdn.net/Mr_wuyongcong/article/details/85208822
今日推荐