7/21下午

1316
复制代码
#include<bits/stdc++.h>
using namespace std;

int n;
int s=0;

void ss(int t){
    s+=t/2;
    for(int m=1; m<=t/2; m++){
        ss(m);
    }
}

int main(){
    cin>>n;
    ss(n);
    cout<<s+1<<endl;
    return 0;
}
复制代码

1206

复制代码
#include<bits/stdc++.h>
using namespace std;

long long f(long long m,long long n){
    if(n==0){
        return 0;
    }else  if(n==1 || m==1 || m==0){
        return 1;
    }else if(n>m){
        return f(m,m);
    }return f(m,n-1)+f(m-n,n);
    
}

int main(){
    int k;
    cin>>k;
    long long m,n;
    for(int i=1; i<=k; i++){    
        cin>>m>>n;
        cout<<f(m,n)<<endl;
    }
    return 0;
}
复制代码

pell(未完成)

复制代码
#include<bits/stdc++.h>
using namespace std;

long long a[1000005];

long long pell(int m){
    if(m==1){
        return 1;
    }else if(m==2){
        return 2;
    }else if(a[m]!=0) {
        return a[m];
    }else {
        a[m]=2*pell(m-1)+pell(m-2) ;
        return a[m];
    }
}

int main(){
    int n;
    cin>>n;
    long long k[1005];
    for(int i=1; i<=n; i++){
        cin>>k[i];
        
    }
    for(int i=1; i<=n; i++){
        int s=pell(k[i])%32767;
        printf("%d\n",s);
    }
    return 0;
}
复制代码

1317组合的输出(未交)

复制代码
#include<bits/stdc++.h>
using namespace std;

int a[105];
int n,r;
bool b[25];

void judge(int y){
    for(int i=y; i<=n; i++){
        if(!b[i] && a[y-1]<i){
            b[i]=true;
            a[y]=i;
            if(y==r){
                for(int j=1; j<=r; j++){
                    printf("%3d",a[j]);
                }
                cout<<endl;
            }else {
                judge(y+1);
            }
            b[i]=false;
        }
    }
}

int main(){
    cin>>n>>r;
    judge(1);
    return 0;
}
复制代码

 1212letters(未完成)

复制代码
#include<bits/stdc++.h>
using namespace std;

int s=1,maxs;
bool a[25][25],b[10005];
char c[25][25];
int R,S;

void dfs(int m,int n){
    if(m<=R && n<=S && m>0 && n>0){
        if(b[c[m][n]]==false && a[m][n]==false){
            s++;
            b[c[m][n]]=true;
            a[m][n]=true;
        }
        dfs(m+1,n);
        dfs(m,n+1);
        if(s>maxs){
            maxs=s;
        }else {
            s--;
            return ;
        }
        b[c[m][n]]=false;
        a[m][n]=false;
        
    }else {
        return ;
    }
    
}

int main(){
    cin>>R>>S;
    for(int i=1; i<=R; i++){
        for(int j=1; j<=S; j++){
            cin>>c[i][j];
        }
    }
    dfs(1,1);
    cout<<maxs<<endl;
    return 0;
}
复制代码

https://blog.csdn.net/weixin_45988242/article/details/104175845(参考答案)

posted @   竹余居居居居居  阅读(6)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示