绝对数量即可

1.2

#include<bits/stdc++.h>
#include<iostream>
#define int long long
#define cout cout<<
#define cin cin>>
#define lsh <<
#define signed signed main()
#define import using namespace
#define quit return
#define finish return 0
import std;
short n;
string st;
void sc(int cur=0){
if(cur==n){
cout st lsh endl;
quit;
}
st += 'a';
sc(cur+1);
st = st.replace(st.length()-1,1,"b");
sc(cur+1);
st = st.replace(st.length()-1,1,"c");
sc(cur+1);
st = st.replace(st.length()-1,1,"");
}
signed{
cin n;
sc();
finish;
}

2.

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;
int n;
int a[10];
int X[10], Y[10];
bool f[10];
long long ans = 0;
double res = 0.0;
void print()
{
    for (int i = 2; i <= n; i++)
    {
        res += sqrt((X[a[i]] - X[a[i - 1]]) * (X[a[i]] - X[a[i - 1]]) + (Y[a[i]] - Y[a[i - 1]]) * (Y[a[i]] - Y[a[i - 1]]));
    }
}
void into(int a[], int b[])
{
    for (int i = 1; i <= n; i++)
    {
        b[i] = a[i];
    }
}
void dfs(int d)
{
    d++;
    if (d == n)
    {
        for (int i = 1; i <= n; i++)
        {
            if (!f[i])
            {
                a[n] = i;
                ans++;
                break;
            }
        }
        print();
        return;
    }
    int b[10];
    into(a, b);
    for (int i = 1; i <= n; i++)
    {
        if (!f[i])
        {
            a[d] = i;
            f[i] = true;
            dfs(d);
            into(b, a);
            f[i] = false;
        }
    }
}
int main()
{
    memset(f, false, sizeof(f));
    memset(a, 0, sizeof(a));
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> X[i] >> Y[i];
    }
    dfs(0);
    printf("%.10lf", res / double(ans));
    return 0;
}

3.

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=18;
int n;
int x[MAXN][MAXN],y[MAXN][MAXN];
int f[MAXN];
int a[MAXN];
int ans=0;
bool cccd()
{
	for(int i=1;i<=n;i++)
	if(f[i]==1)
	for(int j=1;j<=a[i];j++)
	if(f[x[i][j]]!=y[i][j])
	return false;
	return true;
}
void dfs(int pp,int kk)
{
	if(pp==n+1)
	{
	if(cccd())
	ans=max(ans,kk);
	return;
	}
	f[pp]=1;
	dfs(pp+1,kk+1);
	f[pp]=0;
	dfs(pp+1,kk);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
	cin>>a[i];
	for(int j=1;j<=a[i];j++)cin>>x[i][j]>>y[i][j];
	}
	dfs(1,0);
	cout<<ans;
	return 0;
}

4.

#include<iostream>
using namespace std;
int n;
char a[10];
void f(int x,int c)
{
	if(x>n)
	{
		for(int i=1;i<=n;i++)cout<<a[i];
		cout<<endl;
		return;
	}
	else
	{
		for(int i=0;i<=c;i++)
		{
			a[x]=i+'a';
			f(x+1,max(c,i+1));
			a[x]=' ';
		}
	}
}
int main()
{
	cin>>n;
	f(1,0);
} 

5.

#include<iostream>
 using namespace std;
long long h,w,cnt,f[1000][1000],a,b; 
void dfs(int x,int y){
 if(x>h){ 
 y++;
  x=1;
   }
    if(x==h&&y==w){
	 cnt++;
	  return;
	   } 
	   if(f[x][y]){
	    dfs(x+1,y);
		 return ; 
		 }
		  if(y+1<=w&&f[x][y+1]==false&&a>0)
		  {

	a--;

	f[x][y]=true;

	f[x][y+1]=true;

	dfs(x+1,y);

	f[x][y]=false;

	f[x][y+1]=false;

	a++;

}

if(x+1<=h&&f[x+1][y]==false&&a>0){

	a--;

	f[x][y]=true;

	f[x+1][y]=true;

	dfs(x+1,y);

	f[x][y]=false;

	f[x+1][y]=false;

	a++;

}

if(b>0){

	b--;

	f[x][y]=true;

	dfs(x+1,y);

	f[x][y]=false;

	b++;

}
}
int main(){
	cin>>h>>w>>a>>b;
	dfs(1,1);
	cout<<cnt;
}

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值