2013NBUT暑期集训成果赛 赛后总结以及解题报告

//[C] AmeriDarts//
//水题,就是求两个数列中差值最小是多少,普通的暴力遍历就行了,没什么好说的//




#include<stdio.h>
#include<math.h>
int num1[2000];
int num2[2000];
int main()
{
int i,j;
int A,B;
int min=99999;
while(scanf("%d%d",&A,&B)!=EOF)
{
min=99999;
for(i=1;i<=A;i++)
scanf("%d",&num1[i]);
for(i=1;i<=B;i++)
scanf("%d",&num2[i]);
for(i=1;i<=A;i++)
{
for(j=1;j<=B;j++)
if(abs(num1[i]-num2[j])<min)
min=abs(num1[i]-num2[j]);
}
printf("%d\n",min);
}
return 0;
}









//[G] Big Fibonacci*//
/*
仔细一看题目,数据范围那么大就知道肯定要找规律,这种题目一般都会有循环节点,所以打一个表,但是要尽量大一点的表,不然找不出循环节点
循环节点,就是斐波那契数列的开始,即第一项为0,那么利用 
for(i=3;i<=1000000;i++) 
{
num[i]=(num[i-1]+num[i-2])%20130719;
if(num[i]==1&&num[i-1]==0)
{
printf("%d\n",i-1);
break;
}
}

输入的i便是循环节点,那么我们只要求到这个循环节点的斐波那契数列,存好就可以了。之后每次输入N值都对循环节点取余,然后找相应的斐波那契值*/




#include<stdio.h>
long long int num[1000000];
int main()
{
	long long int n;
	int i;

	num[0]=0;
	num[1]=1;
	num[2]=1;
	for(i=3;i<=572881;i++)
		num[i]=(num[i-1]+num[i-2])%20130719;
	while(scanf("%lld",&n)!=EOF)
	{
		printf("%lld\n",num[n%572880]);
	}
	return 0;
}






//[D] 泄密的图片//
/*
是一个简单的模拟题,只要按照题目的要求去做就行,还要注意的是,这个题目的输入是先输入列,再输入行
*/



#include<stdio.h>
#include<string.h>
char A[220][220];
char B[220][220];
char C[220][220];
char D[220][220];
int  result[220][220];
int main()

{
	int N;
	int hang,lie;
	int i,j,k;
	int t;
	scanf("%d",&N);
	while(N--)
	{
		scanf("%d%d",&lie,&hang);
		for(i=1;i<=hang;i++)
			scanf("%s",A[i]);
		for(i=1;i<=hang;i++)
			scanf("%s",B[i]);
		for(i=1;i<=hang;i++)
			scanf("%s",C[i]);
		for(i=1;i<=hang;i++)
			scanf("%s",D[i]);
		for(i=1;i<=hang;i++)
			for(j=0;j<lie;j++)
			{

				if(A[i][j]-48<1&&A[i][j]>7)
					result[i][j]=0;
				else
					if(A[i][j]-48==1)
					{
						result[i][j]=B[i][j]-48;
						if(result[i][j]>=9)
							result[i][j]=9;
					}
					else
						if(A[i][j]-48==2)
						{
							result[i][j]=C[i][j]-48;
							if(result[i][j]>=9)
								result[i][j]=9;
						}
						else
							if(A[i][j]-48==3)
							{
								result[i][j]=B[i][j]-48+C[i][j]-48;
								if(result[i][j]>=9)
									result[i][j]=9;
							}
							else
								if(A[i][j]-48==4)
								{
									result[i][j]=D[i][j]-48;
									if(result[i][j]>=9)
										result[i][j]=9;
								}
								else
									if(A[i][j]-48==5)
									{
										result[i][j]=B[i][j]-48+D[i][j]-48;
										if(result[i][j]>=9)
											result[i][j]=9;
									}
									else
										if(A[i][j]-48==6)
										{
											result[i][j]=C[i][j]-48+D[i][j]-48;
											if(result[i][j]>=9)
												result[i][j]=9;
										}
										if(A[i][j]-48==7)
										{
											result[i][j]=B[i][j]-48+D[i][j]-48+C[i][j]-48;
											if(result[i][j]>=9)
												result[i][j]=9;
										}
			}
			for(i=1;i<=hang;i++)
			{
				for(j=0;j<lie;j++)
				{
					printf("%d",result[i][j]);
				}
				printf("\n");
			}

	}
	return 0;
}




//[A] Bachelor//
/*
题目的意思很明确就是让你计算1---N内有多少个1,那么一个数字的1的个数,就等于这个数字上每一个位数的1的个数的和,进而有三条规律来求每一位数字的1的个数
1、如果一个位数是0,那么该位的1的个数由高位决定。1的个数等于高位*当前位数的倍率(1,10,100,1000);
2、如果一个位数是1,那么该位的1的个数不仅仅由高位决定,还由低位决定,计算公式=高位*当前位数的倍率+当前位至最低位的数字
EG:
如果百位上的数字为1,则可以知道,百位上可能出现1的次数不仅受更高位影响,还受低位影响,也就是由更高位和低位共同决定。
例如12 113, 受更高位影响,百位出现1的情况是100-199,1 100-1 199,……,11 100-11 199,一共有1 200个,和上面第一种情况一样,
等于更高位数字(12)×当前位数(100)。但它还受低位影响,百位出现1的情况是12 000-12 113,一共114个,等于低位数字(113)+1。
3、如果一个位数是大于1,那么该位的1的个数仍然取决于高位,计算公式=(高位+1)*100;

综上所述,每一次算一个位数上的1的个数,最后相加起来
*/


#include<stdio.h>
#include<string.h>
#define LL long long int
long long int SUM(long long int x)
{
	LL low,high,position,beishu;
	LL sum=0;
	beishu=1;
	low=high=position=0;
	while(x/beishu)
	{
		high=x/(beishu*10);
		low=x-x/(beishu)*beishu;
		position=(x/beishu)%10;
		switch(position)
		{
		case 0:sum+=high*beishu; break;
		case 1:sum+=high*beishu+low+1; break;
		default:sum+=(high+1)*beishu;break;
		}
		beishu*=10;
	}
	return sum;
}
int main()
{
	long long int result;
	long long int N;
	while(scanf("%lld",&N)!=EOF)
	{
		result=SUM(N);
		printf("%lld\n",result);
	}
}




//[1479] How many//

/*
题目大意:给你一个序列,让你找出有多少种数字的组合加起来等于给定的和值
思路:
比赛的时候脑残,想暴力,结果感觉肯定TE。但是是可以用搜索做的。其实感觉自己做不出来,还是因为没能理解DFS的实质,你会发现
其实题目的意思已经很明确了,赤裸裸的DFS思想,明摆着的。
从序列中的第一个数字开始,每次向前前进一个,然后以当前的这个为起点再向下进行,如果不能继续搜索,那么就回退。
还要注意的是,如果你一旦用了DFS,还使用了回溯法的框架,在之前做了什么,回溯的时候一定要做相反的工作,因为这样才能做到真正的回溯
感觉王克纯的代码更简单一些。是用逆向思维减法来做的
*/



#include<stdio.h>
int N,sum,count,len;
int he;
int num[65];
void dfs(int k,int max)
{
	int i;
	for(i=k;i<len&&num[i]<=sum;i++)
		if(max+num[i]<=sum)
		{
			if(max+num[i]==sum)
				count++;
			max=max+num[i];
			dfs(i+1,max);
			max=max-num[i];
		}
}
int main()
{
	char d;
	while(scanf("%d",&N)!=EOF)
	{
		while(N--)
		{
			he=0;
			count=0;
			scanf("%d%d",&len,&sum);
			for(int i=0;i<len;i++)
				scanf("%d%c",&num[i],&d);	
			dfs(0,0);
			printf("%d\n",count);
		}
	}
	return 0;
}



//[H] 嘛~付钱吧!//

//大表过的,下面是打表的程序//



#include<stdio.h>
#include<string.h>
int num[1200];
int result[1200];
int main()
{
	int b1,b2,b3,b4,b5;
	int count;
	freopen("f:\\out.txt","w",stdout);
	int t;
	int y;
	for(t=0;t<1200;t++)
		num[t]=t;
	y=0;
	for(y=0;y<=1000;y++)
	{
		for(int i = 0;i <= 10;i++)
		{
			b1=i*100;
			if(b1<=num[y])
			for(int j = 0;j <= 20;j++)
			{
				b2=b1+j*50;
				if(b2<=num[y])
				for(int k = 0;k <= 50;k++)
				{
					b3=b2+k*20;
						if(b3<=num[y])
					for(int l = 0;l <= 100;l++)
					{
						b4=b3+l*10;
						if(b4<=num[y])
						for(int m = 0;m <= 200;m++ )
						{
							b5=b4+m*5;
							if(b5<=num[y])
							{
								result[num[y]]++;
							}
						}
					}
				}
			}
		}
	}
	for(y=0;y<=1000;y++)
		printf("%d,",result[y]);

	return 0;
}


#include<stdio.h>
int num[1050]={0,1,1,1,1,2,2,2,2,2,4,4,4,4,4,6,6,6,6,6,10,10,10,10,10,14,14,14,14,14,20,20,20,20,20,26,26,26,26,26,35,35,35,35,35,44,44,44,44,44,57,57,57,57,57,70,70,70,70,70,88,88,88,88,88,106,106,106,106,106,130,130,130,130,130,154,154,154,154,154,185,185,185,185,185,216,216,216,216,216,255,255,255,255,255,294,294,294,294,294,344,344,344,344,344,394,394,394,394,394,456,456,456,456,456,518,518,518,518,518,595,595,595,595,595,672,672,672,672,672,765,765,765,765,765,858,858,858,858,858,970,970,970,970,970,1082,1082,1082,1082,1082,1216,1216,1216,1216,1216,1350,1350,1350,1350,1350,1509,1509,1509,1509,1509,1668,1668,1668,1668,1668,1855,1855,1855,1855,1855,2042,2042,2042,2042,2042,2260,2260,2260,2260,2260,2478,2478,2478,2478,2478,2730,2730,2730,2730,2730,2982,2982,2982,2982,2982,3274,3274,3274,3274,3274,3566,3566,3566,3566,3566,3901,3901,3901,3901,3901,4236,4236,4236,4236,4236,4620,4620,4620,4620,4620,5004,5004,5004,5004,5004,5440,5440,5440,5440,5440,5876,5876,5876,5876,5876,6370,6370,6370,6370,6370,6864,6864,6864,6864,6864,7422,7422,7422,7422,7422,7980,7980,7980,7980,7980,8608,8608,8608,8608,8608,9236,9236,9236,9236,9236,9940,9940,9940,9940,9940,10644,10644,10644,10644,10644,11430,11430,11430,11430,11430,12216,12216,12216,12216,12216,13090,13090,13090,13090,13090,13964,13964,13964,13964,13964,14936,14936,14936,14936,14936,15908,15908,15908,15908,15908,16984,16984,16984,16984,16984,18060,18060,18060,18060,18060,19250,19250,19250,19250,19250,20440,20440,20440,20440,20440,21750,21750,21750,21750,21750,23060,23060,23060,23060,23060,24500,24500,24500,24500,24500,25940,25940,25940,25940,25940,27520,27520,27520,27520,27520,29100,29100,29100,29100,29100,30830,30830,30830,30830,30830,32560,32560,32560,32560,32560,34450,34450,34450,34450,34450,36340,36340,36340,36340,36340,38400,38400,38400,38400,38400,40460,40460,40460,40460,40460,42700,42700,42700,42700,42700,44940,44940,44940,44940,44940,47375,47375,47375,47375,47375,49810,49810,49810,49810,49810,52450,52450,52450,52450,52450,55090,55090,55090,55090,55090,57950,57950,57950,57950,57950,60810,60810,60810,60810,60810,63900,63900,63900,63900,63900,66990,66990,66990,66990,66990,70325,70325,70325,70325,70325,73660,73660,73660,73660,73660,77255,77255,77255,77255,77255,80850,80850,80850,80850,80850,84720,84720,84720,84720,84720,88590,88590,88590,88590,88590,92750,92750,92750,92750,92750,96910,96910,96910,96910,96910,101375,101375,101375,101375,101375,105840,105840,105840,105840,105840,110625,110625,110625,110625,110625,115410,115410,115410,115410,115410,120536,120536,120536,120536,120536,125662,125662,125662,125662,125662,131144,131144,131144,131144,131144,136626,136626,136626,136626,136626,142485,142485,142485,142485,142485,148344,148344,148344,148344,148344,154595,154595,154595,154595,154595,160846,160846,160846,160846,160846,167510,167510,167510,167510,167510,174174,174174,174174,174174,174174,181272,181272,181272,181272,181272,188370,188370,188370,188370,188370,195923,195923,195923,195923,195923,203476,203476,203476,203476,203476,211505,211505,211505,211505,211505,219534,219534,219534,219534,219534,228060,228060,228060,228060,228060,236586,236586,236586,236586,236586,245630,245630,245630,245630,245630,254674,254674,254674,254674,254674,264264,264264,264264,264264,264264,273854,273854,273854,273854,273854,284011,284011,284011,284011,284011,294168,294168,294168,294168,294168,304920,304920,304920,304920,304920,315672,315672,315672,315672,315672,327040,327040,327040,327040,327040,338408,338408,338408,338408,338408,350420,350420,350420,350420,350420,362432,362432,362432,362432,362432,375116,375116,375116,375116,375116,387800,387800,387800,387800,387800,401184,401184,401184,401184,401184,414568,414568,414568,414568,414568,428680,428680,428680,428680,428680,442792,442792,442792,442792,442792,457660,457660,457660,457660,457660,472528,472528,472528,472528,472528,488180,488180,488180,488180,488180,503832,503832,503832,503832,503832,520304,520304,520304,520304,520304,536776,536776,536776,536776,536776,554096,554096,554096,554096,554096,571416,571416,571416,571416,571416,589620,589620,589620,589620,589620,607824,607824,607824,607824,607824,626940,626940,626940,626940,626940,646056,646056,646056,646056,646056,666120,666120,666120,666120,666120,686184,686184,686184,686184,686184,707232,707232,707232,707232,707232,728280,728280,728280,728280,728280,750348,750348,750348,750348,750348,772416,772416,772416,772416,772416,795540,795540,795540,795540,795540,818664,818664,818664,818664,818664,842880,842880,842880,842880,842880,867096,867096,867096,867096,867096,892440,892440,892440,892440,892440,917784,917784,917784,917784,917784,944301,944301,944301,944301,944301,970818,970818,970818,970818,970818,998544,998544,998544,998544,998544,1026270,1026270,1026270,1026270,1026270,1055250,1055250,1055250,1055250,1055250,1084230,1084230,1084230,1084230,1084230,1114500,1114500,1114500,1114500,1114500,1144770,1144770,1144770,1144770,1144770,1176375,1176375,1176375,1176375,1176375,1207980,1207980,1207980,1207980,1207980,1240965,1240965,1240965,1240965,1240965,1273950,1273950,1273950,1273950,1273950,1308360,1308360,1308360,1308360,1308360,1342770,1342770,1342770,1342770,1342770,1378650,1378650,1378650,1378650,1378650,1414530,1414530,1414530,1414530,1414530,1451925,1451925,1451925,1451925,1451925,1489320,1489320,1489320,1489320,1489320,1528275,1528275,1528275,1528275,1528275,1567230,1567230,1567230,1567230,1567230,1607800,1607800,1607800,1607800,1607800,1648370,1648370,1648370,1648370,1648370,1690600,1690600,1690600,1690600,1690600,1732830,1732830,1732830,1732830,1732830,1776775,1776775,1776775,1776775,1776775,1820720,1820720,1820720,1820720,1820720,1866425,1866425,1866425,1866425,1866425,1912130,1912130,1912130,1912130,1912130,1959650,1959650,1959650,1959650,1959650,2007170,2007170,2007170,2007170,2007170,2056560,2056560,2056560,2056560,2056560,2105950,2105950,2105950,2105950,2105950,2157265,2157265,2157265,2157265,2157265,2208580,2208580,2208580,2208580,2208580,2261875,2261875,2261875,2261875,2261875,2315170,2315170,2315170,2315170,2315170,2370500,2370500,2370500,2370500,2370500,2425830,2425830,2425830,2425830,2425830,2483250,2483250,2483250,2483250,2483250,2540670,2540670,2540670,2540670,2540670,2600246};
int main()
{
	int N;
	while(scanf("%d",&N)!=EOF)
	{
		printf("%d\n",num[N]);
	}
	return 0;
}










你可能感兴趣的:(2013NBUT暑期集训成果赛 赛后总结以及解题报告)