1. 程式人生 > >歡樂紀中某B組賽【2018.12.22】

歡樂紀中某B組賽【2018.12.22】

前言

全暴力第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>>