1096. Consecutive Factors (20)-PAT甲级真题 经验分享和心路历程

博客提及一道算法题题干链接,后续表示主要时间用于学习做题,考前会进行一次模拟并象征性记录时间,涉及C++、算法等信息技术内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题干:https://pintia.cn/problem-sets/994805342720868352/problems/994805370650738688

题解:之后的时间主要去学习做题了,考前再模拟一次,时间象征性的记一下

// A1096.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

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

int main()
{
#ifndef ONLINE_JUDGE
    FILE* s;
    freopen_s(&s, "in.txt", "r", stdin);
#endif // !ONLINE_JUDGE

    long long n;
    cin >> n;
    //len=12;
    int max = sqrt(n);
    bool flag = false;
    int len;
    int start;
    for (len = 12; len >= 1; len--) {
        for (start = 2; start <= max; start++) {
            long long  ans = 1;
            for (int i = start; i<start+len; i++) {
                ans *= i;
            }
            if (n % ans == 0) {
                flag = true;
                break;
            }
        }
        if (flag)break;
    }
    cout << len<<endl;
    cout << start;
    for (int i = start+1; i < start + len; i++) {
        cout << "*" << i;
    }
    return 0;
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Exodus&Focus

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值