2016蓝桥C语言B组√

171700

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int l=0;
	int sum=0;
	for(int i=1;i<=100;i++)
	{
		l+=i;
		sum+=l;
	}
	cout<<sum<<endl;
	return 0;
}

26

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	for(int s=1;s<100;s++)
	{
		for(int y=1;y<100;y++)
		{
			if((s+s+y-1)*y/2==236)
			{
				cout<<s<<endl;
				return 0;
			}
		}
	}
	return 0;
}

3.凑算式
A~B ——1~9
在这里插入图片描述
29

#include<iostream>
#include<cstdio>
using namespace std;
int res=0;
int a[10];
bool vis[15];
void seek(int d)
{
	if(d>=9)
	{
		if((a[0]+(double)a[1]/a[2]+(double)(a[3]*100+a[4]*10+a[5])/(a[6]*100+a[7]*10+a[8]))==10)res++;//double
		return;
	}
	for(int i=1;i<=9;i++)
	{
		if(!vis[i])
		{
			a[d]=i;
			vis[i]=1;
			seek(d+1);
			vis[i]=0;
		}
	}
}
int main()
{
	seek(0);
	cout<<res<<endl;
	return 0;
}

4.快速排序

swap(a,p,j)

5.抽签
给定字符种类数量求在规定长度有多少种组法

f(a,k+1,m-j,b)

6.方格填数

1580
(回溯)

7.剪邮票

116
(还好是填空题哈哈哈哈哈哈 还是要好好看看别人的做法)

8.四平方和

9.交换瓶子

10.最大比例

猜你喜欢

转载自blog.csdn.net/weixin_40367307/article/details/88560267