• hdu 1405 The Last Practice 输出格式需注意


    #include<stdio.h>
    #include<string.h>
    #include<vector>
    #define N 65536
    using namespace std;
    int prime[N];
    bool visit[N];
    struct node
    {
        int x,y;
    } cpt;
    vector<node>v;
    int num=0;
    int prim()
    {
        memset(visit,true,sizeof(visit));
        for(int i=2; i<=N; i++)
        {
            if(visit[i]==true)
            {
                num++;
                prime[num]=i;
            }
            for(int j=1; j<=num&&i*prime[j]<=N; j++)
            {
                visit[i*prime[j]]=false;
                if(i%prime[j]==0)break;
            }
        }
        return 0;
    }
    int main()
    {
        int n;
        prim();
        int _case=0;
        while(scanf("%d",&n)!=EOF&&n>0)
        {
            v.clear();
            for(int i=1; i<num&&n>=prime[i]; i++)
            {
                if(n%prime[i]==0)
                {
                    cpt.x=prime[i];
                    cpt.y=1;
                    n/=prime[i];
                    while(n%prime[i]==0)
                    {
                        cpt.y++;
                        n/=prime[i];
                    }
                    v.push_back(cpt);
                }
    
            }
            if(_case>0)
            printf("\n");//!!!!!!!!!!
            printf("Case %d.\n",++_case);
            printf("%d %d ",v[0].x,v[0].y);
            for(int i=1;i<v.size();i++)
                printf("%d %d ",v[i].x,v[i].y);//!!!!!!!!!!
            printf("\n");
        }
        return 0;
    }
  • 相关阅读:
    每周总结8.18
    每周总结7.28
    每周总结8.25
    每周总结7.21
    每周总结8.11
    每周总结8.4
    大道至简 读后感
    递归进行回文的判断
    课后作业1
    GoodBlogs Websites
  • 原文地址:https://www.cnblogs.com/XDJjy/p/3107030.html
Copyright © 2020-2023  润新知