zoukankan      html  css  js  c++  java
  • 无关的元素

    #include <bits/stdc++.h>
    using namespace std;
    //无关的元素.png
    //算法入门经典
    // 组合数Cmn很大,很有可能溢出,真的非常大,类似于n!,即使longlong也存不下
    // 在这种情况下 可以考虑 用组合数递推公式,这样从1开始每次对(n-k+1)/k进行素因子分解然后累加,
    //就得到了每个的分解结果,但是要注意(n-k+1)/k可能<1所以还要分情况,
    //在<1时只能把分母的值用已经得到的上次的C值消去,肯定可以消去
    int n,m;
    map<int,int> yinzi;//m的素因子及其个数
    void fenjie(){
        int i=2,x=m,s=0;
        while(x>1){
            while(x%i==0){
                x=x/i;
                s++;
            }
            if(x%i!=0){
                if(s!=0){
                    yinzi.insert(make_pair(i,s));
                    cout<<i<<" "<<s<<endl;
                }
                s=0;
                i++;
            }
        }
    }
    int main()
    {   
        // //m>=2,所以a1 an都不行
        // while(cin>>n>>m){
        //     yinzi.clear();
        //     fenjie();
        //     int oks=0,p[yinzi.size()]={0},flg=1,index;
        //     memset(p,0,sizeof(p));
        //     for(int i=1;i<n-1;i++){
        //         int k;
        //         if(n-i<i) {flg=-1;k=i/(n-i);}
        //         else k=(n-i)/i;
        //         index=0;
        //         cout<<k<<endl;
        //         for(map<int,int>::iterator it=yinzi.begin();it!=yinzi.end();it++){
        //             // cout<<it->first<<endl;
        //             while(k%(it->first)==0){
        //                 k=k/(it->first);
        //                 p[index]+=flg;
        //                 if(p[index]==it->second){
        //                     oks+=flg;
        //                 }
        //             }
        //             // cout<<p[index]<<endl;
        //             index++;
        //         }
        //         // cout<<oks<<endl;
        //         for(int pp=0;pp<5;pp++) cout<<p[pp]<<" ";cout<<endl;
        //         if(oks==yinzi.size()) cout<<"a"<<i+1<<" ";
        //     }
        //     cout<<endl;
        // }
        return 0;
    }
  • 相关阅读:
    构造方法
    linux操作系统基础篇(四)
    linux操作系统基础篇(三)
    linux操作系统基础篇(二)
    linux操作系统基础篇(一)
    计算机网络基础
    计算机操作系统
    计算机基础!
    Open vSwitch intro
    Less(11)
  • 原文地址:https://www.cnblogs.com/MorrowWind/p/13056505.html
Copyright © 2011-2022 走看看