7.31

· · 个人记录

递归解释

声明函数

int fff(int n)
{
    if(n==0)return n;
    return n+fff(n-1);
}

错题修改

1.B3914 [语言月赛 202401] 分饼干 I

错误原因

把他想得太复杂啦!

错误代码

#include<bits/stdc++.h>
using namespace std;

int main() {
    int a[13];
    cin>>a[1]>>a[2]>>a[3]; 
    int c=INT_MAX;
    int s=0,d=0;
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
        {
            for(int k=1;k<=3;k++)
            {
                int z,yz;
                if(j!=k!=i)
                {
                    if(a[i]>a[j]+a[k])
                    {
                        z=a[i];
                        yz=a[j]+a[k];
                        if(z>yz)
                        {
                            if(z-yz<=c)
                            {
                                c=z-yz;
                                s=z;
                                d=yz;
                            }
                        }
                    }
                    else
                    {
                        z=a[j]+a[k];
                        yz=a[i];
                        if(z>yz)
                        {
                            if(z-yz<=c)
                            {
                                c=z-yz;
                                s=z;
                                d=yz;
                            }
                        }   
                    }
                }
            }
        } 
    }
    cout<<s<<" "<<d;
    return 0;
}

泰富砸啦!!!!!!!

贞雀代码

#include<bits/stdc++.h>
using namespace std;

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a>c)
    {
        int t=a;
        a=c;
        c=t;
    }
    if(b>c)
    {
        int t=b;
        b=c;
        c=t;
    }
    cout<<max(a+b,c)<<" "<<min(a+b,c);
    return 0;
}

2.P5315 头像上传

错误原因

他妈超时啦!

错误代码

#include<bits/stdc++.h>
using namespace std;

int main() {
    int n,l,g;
    cin>>n>>l>>g;
    for(int i=1;i<=n;i++)
    {
        int w,h;
        cin>>w>>h;

        while(h<=g&&w<=g)
        {
            if(w>g)w/=2;
            if(h>g)w/=2;
            if(w>g&&h>g)
            {
                w/=2;
                h/=2;
            }
        }
        if(w<l||h<l)
        cout<<"Too Young"<<endl;
        else if(w*h>=l*l&&w!=h)
        cout<<"Too Simple"<<endl;
        else if(w*h>=l*l&&w==h)
        cout<<"Sometimes Naive"<<endl;
    }
    return 0;
}

真确代码

#include<bits/stdc++.h>
using namespace std;

int main() {
    int n,l,g;
    cin>>n>>l>>g;
    for(int i=1;i<=n;i++)
    {
        int w,h;
        cin>>w>>h;
        while(w>g||h>g)
        {
            w/=2;
            h/=2;
        }
        if(w<l||h<l)
        cout<<"Too Young"<<endl;
        else if(w*h>=l*l&&w!=h)
        cout<<"Too Simple"<<endl;
        else if(w*h>=l*l&&w==h)
        cout<<"Sometimes Naive"<<endl;
    }
    return 0;
}

3.B2148 再求 f(x,n)

错误原因

牢屎出的 不会啊

真确垈马

#include<bits/stdc++.h>
using namespace std;
double ff(double x,int n)
{
    if(n==1)return x/(1+x);//判断
    return x/(n+ff(x,n-1));
}
int main() {
    int n;
    double x;
    cin>>x>>n; 
    cout<<fixed<<setprecision(2)<<ff(x,n);//输出
    return 0;
}

4.U523561 汉诺塔

错误原因

牢屎出的 不会啊

真确垈马

#include<bits/stdc++.h>
using namespace std;
void ff(int n,char st,char mid,char ed)
{
    if(n==1)
    {
        cout<<st<<" -> "<<ed<<endl;
        return;
    }
    ff(n-1,st,ed,mid);
    ff(1,st,mid,ed);
    ff(n-1,mid,st,ed);
}
int main() {
    int n;

    cin>>n; 
    ff(n,'A','B','C');
    return 0;
}

5.U143068 2的幂次方表示

错误原因

牢屎出的 不会啊

真确垈马

#include<bits/stdc++.h>
using namespace std;
int pow2[25];
void f(int x)
{
    for(int i=15;i>=0;i--)
    {
        if(pow2[i]<=x)
        {
            if(i==0)cout<<"2(0)";
            else if(i==1)cout<<"2";
            else
            {
                cout<<"2(";
                f(i);
                cout<<")";
            }
            x-=pow2[i];
            if(x>0)cout<<"+";
        }

    }
}

int main() {

    int n;
    cin>>n;
    pow2[0]=1;
    for(int i=1;i<=15;i++)pow2[i]=pow2[i-1]*2;
    f(n);
    return 0;
}

牢屎泰老6啦,让我们写文章!!!!!

抗议的举手

🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚🤚

老屎是个SB大聪明😡

老屎不配当老师😡😡😡😡😡😡😡