• 【CSDN竞赛第五期】编程竞赛体验感受


    建议以及感受

    • 比赛当天网站直接崩溃,体验极差,直到中午才修好
    • 有些题意的输入输出并不明确
    • 在线IDE不完善也不好用,很多bug详见竞赛讨论贴
    • 完赛没有官方题解,或者说讨论题解的人很少
    • 领取奖励还需要撰写一篇比赛相关的博客,有点捆绑的意思,初心可能是为了让大家写题解?
    • 总共参加三次竞赛感受都不好,暂时不会参加CSDN竞赛了,转力扣

    在这里插入图片描述

    题解

    题目一

    寻找因子个数为n的最小整数x

    输入描述:输入整数n。(1<=n<=1000)

    输出描述:输出x。

    示例1:

    输入 3,输出 4;

    解释:因子个数为3的最小整数为4,4具有3个因数,分别为:1,2,4

    #include
    #include
    using namespace std;
    int ans[1000010],cnt[1000010];
    int main (){
    	std::ios::sync_with_stdio(false);
    	memset(ans,-1,sizeof(ans));
    	for(int i = 1; i <= 1000005;i++){
    		for(int j = i;j <= 1000005;j+=i){
    			cnt[j]++;
    			}
    		if(ans[cnt[i]]==-1)
    		ans[cnt[i]]=i;
    	}
    	int n;
    	cin>>n;
    	cout<<ans[n]<<endl;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    题目二

    X国发行货币最高面额为n。 次高面额为n的因子。 以此类推。 X国最多发行多少种货币。

    输入描述:输入整数n。(1<=n<=1000000) 表示货币的最大面额

    输出描述:输出货币的种类。

    示例1:输入 10,输出 3

    import java.util.ArrayList;
    import java.util.Scanner;
    
    class Main {
        public static void main(String[] args) {
            Scanner scan = new Scanner(System.in);
            String str_0 = scan.nextLine().trim();
            int n = Integer.parseInt(str_0);
            scan.close();
            int result = solution(n);
            System.out.println(result);
        }
    
        public static int solution(int n) {
            int result = 0;
            while (n != 1) {
                result++;
                for (int i = 2; i <= n; i++) {
                    if (n % i == 0) {
                        n /= i;
                        break;
                    }
                }
            }
            result++;
            return result;
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
  • 相关阅读:
    Vue接收接口返回的mp3格式数据并支持在页面播放音频
    入职字节外包一个月,我离职了
    C# - 类与类之间的继承关系判断
    多制式射频信号发生器 信号源
    16.0、C语言——指针详解(2)
    HTML常见标签和作用
    网络程序通信的流程
    【libcurl】7.8.4 MT v142 构建
    Postgresql源码(75)notify与listen执行流程分析
    【JavaWeb从入门到实战】MySQL进阶下篇之多表查询&事务
  • 原文地址:https://blog.csdn.net/qq_46207024/article/details/126804218