UCF Local Programming Contest 2018

比赛链接

C题 解题思路:


给予长度为n的数组,数值为 1- n ,可以将数组的数移动到最前或最后的位置,求最后数组从小到大排序时操作的最小次数。

我们发现规律,其中不需要移动的就是连续的上升子序列,所以我们求出最长的连续上升子序列 res, 然后输出 n - res 即可。

代码:
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100010;

int n;
int dp[N];

int main()
{
    cin >> n ;
    int res = 0;
    for (int i = 1, x; i <= n; i++){
        scanf("%d",&x);
        dp[x] = dp[x -1] + 1;
        res = max(dp[x],res);
    }

    cout << n - res << endl;

    return 0;
}



D题 解题思路:


这题比较迷,只要是根据第一个公式得出式子,X * Y= 10 ^ z , 因此可以得出 X 是 2,5的倍数的乘积。

再由 X * W = N, 那么我们算 有多少个 2 和 5 因子的组合就OK。


代码:
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;

ll ans[100010];

ll mod_exp(ll a,ll b){
    ll res = 1;
    ll exp = a;
    while(b){
        if (b & 1) res = res * exp;
        exp = exp * exp;
        b>>=1;
    }
    return res;
}

int main(){
    ll n;
    scanf("%lld",&n);
    int a = 0, b = 0;
    while(n % 2 == 0 && n != 0){
        a ++;
        n /= 2;
    }
    while(n % 5 == 0 && n != 0){
        b ++;
        n /= 5;
    }
    int m = 0;
    for (int i = 0; i <= a; i ++){
        ll x = mod_exp(2,i);
        for (int j = 0; j <= b; j ++){
            ll y = mod_exp(5,j);
            ans[m++] = x * y;
        }
    }
    sort(ans, ans + m);
    printf("%d\n", m);
    for (int i = 0; i < m; i++){
        printf("%lld\n",ans[i]);
    }
    return 0;
}




H题 解题思路:



一开始想麻烦了,以为是循环的那种,然后结果是暴力。
从0循环到999就OK,判断下取最小值(0 的时候一开始没看见)


代码:
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100010;

bool a[10];
int b[10000];

int t, m;

bool check(int x){
    if (x == 0 && !a[0]) return false;
    int k = m;
    while(x){
        int l = x % 10;
        if (!a[l]) return false;
        x /= 10;
    }
    return true;
}

int main()
{
    int n;
    memset(a,true, sizeof a);
    scanf("%d",&n);
    for (int i = 0, x; i < n; i++){
        scanf("%d",&x);
        a[x] = false;
    }
    scanf("%d",&m);
    int res = 1000;
    for (int i = 1; i <= 999; i ++){
        if (check(i)){
            res = min(res,abs(m - i));
        }
    }
    printf("%d",res);
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据您提供的引用内容,我可以告诉您关于Vivado 2018.3无法加载UCF文件的情况。 根据引用,在Vivado中启用容错功能可以通过启用"Enable Fault Tolerance Support"选项来实现。这个选项在异常处理的第三页中找到。不过,从您的问题来看,并没有明确提到容错功能与UCF文件的关系。 根据引用,您提到在Vivado IP目录中没有找到AXI Slave Burst IP。这可能是因为IP的名称已经更改了,或者可能有其他原因导致您无法在Vivado中找到该IP。您可以尝试查看Vivado的其他资源或者参考其他文档来寻找所需的IP。 至于Vivado 2018.3无法加载UCF文件的问题,根据您提供的资料,没有明确的信息解释这个问题。如果您遇到了无法加载UCF文件的问题,我建议您检查UCF文件的格式以及与Vivado版本的兼容性。也可以参考引用中提供的链接,里面可能包含了关于UCF文件的一些有用信息。 总结起来,如果您在Vivado 2018.3中无法加载UCF文件,您可以检查UCF文件的格式和兼容性,并可以参考其他资源来解决该问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [利用Vivado进行MicroBlaze处理器应用教程](https://blog.csdn.net/weiaipan1314/article/details/110674762)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [ISE14.7工程移植到VIVADO](https://blog.csdn.net/u011329967/article/details/119683307)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值