头像

Acwing_ikun

成都信息工程大学




离线:8小时前


最近来访(64)
用户头像
code_kekelin
用户头像
say774
用户头像
易思人
用户头像
lilydeng
用户头像
理塘の纯真一郎
用户头像
Flyinsky
用户头像
Apricity_1
用户头像
andy20110427
用户头像
純真丁一郎です
用户头像
lhf123
用户头像
The_Acute.
用户头像
tianpan
用户头像
Colin_Stack
用户头像
honghong_Bye
用户头像
微风入我怀
用户头像
WangJY
用户头像
胡想
用户头像
中微子_
用户头像
yydsw2x
用户头像
ikun604


https://aigpt2.xxce.cn/

PS:你问机器人是几的版本,都是3.5,就算在官网用20刀买的问也是3.5,网上有许多辨别方式,可以看看。
比如:今天几日(概率不回复,回复2022年时间的就是4.0.2021时间的就是3.5)
下面是免费卡密,注册后登录在个人中心兑换后即可使用GPT4.0

还有就是默认是3.5的模型,你需要切换到4.0模型才行

5zox1tDuQCBNa98z
dXPTVMT8pHbL3sDL
VqdSZniL3hlo8yQ2
SSRgNVWWMXnj3Gqe
GIQSuA1H01hHYJx9
MIBFjhmdp0LAGvFI
cpmz1g1C6tQOwYCo
DFSjFxQM3oeqrKxA
dHPt44AnZkbgsTt3
JEdVJRC083XBFL3I




https://aigpt2.xxce.cn/

PS:你问机器人是几的版本,都是3.5,就算在官网用20刀买的问也是3.5,网上有许多辨别方式,可以看看。
比如:今天几日(概率不回复,回复2022年时间的就是4.0.2021时间的就是3.5)
下面是免费卡密,注册后登录在个人中心兑换后即可使用GPT4.0

还有就是默认是3.5的模型,你需要切换到4.0模型才行

5zox1tDuQCBNa98z
dXPTVMT8pHbL3sDL
VqdSZniL3hlo8yQ2
SSRgNVWWMXnj3Gqe
GIQSuA1H01hHYJx9
MIBFjhmdp0LAGvFI
cpmz1g1C6tQOwYCo
DFSjFxQM3oeqrKxA
dHPt44AnZkbgsTt3
JEdVJRC083XBFL3I




题目解析
题目描述
给定一个正整数 m,请你统计一共有多少个正整数 n 满足,n 的阶乘的末尾连续 0 的数量恰好为 m。输出满足条件的 n 的数量以及所有满足条件的 n。

思路分析
我们可以发现,阶乘末尾的 0 是由 2 和 5 相乘产生的。在阶乘中,因子 2 的数量总是大于因子 5 的数量,所以我们只需要关注因子 5 的数量即可。

首先我们需要一个函数 count_trailing_zeros 来计算 n! 中末尾连续 0 的个数。这个函数会不断地将 n 整除以 5,并累加结果,直到 n 小于 5。

接下来,我们需要找到所有满足条件的正整数 n。根据题意,n! 中末尾连续零的个数恰好等于 m,则有:

Copycount_trailing_zeros(n) == m
我们可以使用二分查找法在范围 [1, m * 5] 内查找符合条件的正整数 n。当找到一个符合条件的 n 时,向左和向右扩展该区间内满足条件的所有正整数,并将它们添加到结果列表中。

最后输出结果列表即可。

实现代码



 #include <iostream>
#include <vector>

using namespace std;

int count_trailing_zeros(int n) {
    int count = 0;
    while (n >= 5) {
        n /= 5;
        count += n;
    }
    return count;
}

vector<int> find_numbers_with_m_trailing_zeros(int m) {
    int low = 1, high = m * 5;
    vector<int> results;

    while (low <= high) {
        int mid = (low + high) / 2;
        int zeros = count_trailing_zeros(mid);

        if (zeros == m) {
            int left = mid - 1, right = mid + 1;

            while (count_trailing_zeros(left) == m)
                left--;

            while (count_trailing_zeros(right) == m)
                right++;

            for (int i = left + 1; i < right; ++i)
                results.push_back(i);
            break;
        } else if (zeros < m) {
            low = mid + 1;
        } else {
            high = mid - 1;
        }
    }

    return results;
}

int main() {
    int m;
    cin >> m;

    vector<int> numbers_with_m_trailing_zeros = find_numbers_with_m_trailing_zeros(m);

    if (!numbers_with_m_trailing_zeros.empty()) {
        cout << numbers_with_m_trailing_zeros.size() << endl;
        for (int number : numbers_with_m_trailing_zeros)
            cout << number << " ";
        cout << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}




多的不说直接上链接

http://xxt.xxce.cn/




Acwing_ikun
1个月前

ChatGPT 国内免费用

电脑桌面端 安卓app 网页端 免费使用!


网页端: https://aigpt.xxce.cn/?invite_code=QWZABY

桌面端: https://wwq.lanzouo.com/iFmgM0smyn7a

写作业,论文,学习必备,提高学习效率!




Acwing_ikun
1个月前
class Solution {

    public int NumberOf1(int n) {
        int res = 0;
        for(int i = 0;i <= 31; i ++)
        {

                res += n>>i&1;

        }

        return res;
    }


}



Acwing_ikun
1个月前
class Solution {

    public void reOrderArray(int[] array) {
        int cnt1 = 0, cnt2 = 0;
        int[] jishu = new int [101];
        int[] oushu = new int [101];
        for(int num: array)
        {
            if(num%2!=0)
            {
                jishu[++cnt1] = num;
            }else
            {
                oushu[++cnt2] = num;
            }
        }
        for(int i = 1; i <= array.length; i ++)
        {
            if(i<=cnt1)
            {
                array[i-1] = jishu[i];
            }else
            {
                array[i-1] = oushu[i - cnt1];
            }
        }
    }
}



Acwing_ikun
1个月前
class Solution {
    public int getMissingNumber(int[] nums) {
        int res = 0;
        HashMap<Integer, Integer> hp = new HashMap<>();
        for(int num : nums)
        {
            hp.put(num,1);

        }
        for(int i = 0; i < nums.length + 1; i ++)
        {
            if(hp.containsKey(i) == false)
            {
                res = i;
            }
        }
        return res;
    }
}



Acwing_ikun
1个月前
class Solution {
    public int getNumberOfK(int[] nums, int k) {
        int cnt = 0;
        for(int num:nums)
        {
            if(num == k)
            {
                cnt ++;
            }
        }
        return cnt;
    }
}


活动打卡代码 AcWing 828. 模拟栈

Acwing_ikun
1个月前
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        Stack<Integer> st = new Stack<>();
        while(t -- > 0)
        {
            String s = sc.next();
            if("push".equals(s))
            {
                int x = sc.nextInt();
                st.push(x);
            }else{
                if("query".equals(s)){
                    System.out.println(st.peek());
                }else if("pop".equals(s))
                {
                    st.pop();
                }else if("empty".equals(s))
                {
                    if(st.empty())
                    {
                        System.out.println("YES");
                    }else
                    {
                        System.out.println("NO");
                    }
                }
            }
        }
    }
}