2022/3/03程式培力進階刷題記錄

刷題證明

 

ACodeForces 1057ABmail Computer Network
#include<bits/stdc++.h>
using namespace std;
int record[200005] = {}, ans[200005] = {};
int main()
{
    int end; int count = 0;
    cin >> end;
    for (int i = 2; i <= end; i++)
    {
        cin >> record[i];
    }
    int temp = end;
    while (temp != 1)
    {
        ans[++count] = temp;
        temp = record[temp];
    }
    ans[++count] = 1;
    for (int i = count;i >= 1; i--)
    {
        printf("%d ", ans[i]);
    }
    return 0;

}

 

BUVA 441Lotto

 

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int flag=0;
    int n=0,a,b,c,d,e,f;
    int ans[100];
    while(cin>>n)
    {
        if(flag!=0&&n!=0)
        {
            cout<<endl;
        }
        if(n==0)break;
        for(int i=0;i<n;i++)cin>>ans[i];
        for(a=0;a<n-5;a++)
        {
            for(b=a+1;b<n-4;b++)
            {
                for(c=b+1;c<n-3;c++)
                {
                    for(d=c+1;d<n-2;d++)
                    {
                        for(e=d+1;e<n-1;e++)
                        {
                            for(f=e+1;f<n;f++)
                            {
                                cout<<ans[a]<<" "<<ans[b]<<" "<<ans[c]<<" "<<ans[d]<<" "<<ans[e]<<" "<<ans[f]<<endl;
                            }
                        }
                    }
                }
            }
        }
        flag++;
    }
    
    return 0;
    
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值