栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 1801 EKG Sequence

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 1801 EKG Sequence

#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;const int maxn=1000000+5;inline void debug(){    printf("where is wrong?n");}inline int max(int a,int b){    return a>b?a:b;}inline int min(int a,int b){    return a<b?a:b;}int res[maxn]={0};int a[maxn];int b[maxn]={0};inline void make_table(){   int i,j,n,cur,k,an,p;   res[1]=1;   res[2]=2;   for(i=0;i<maxn;i++)    a[i]=i;    a[2]=4;   for(i=2;i<maxn;i++)   {      if(b[i]==0)      {        for(j=1;i*j<maxn;j++)        { if(b[i*j]==0)     b[i*j]=i;        }      }   }   cur=2;   for(n=2;n<maxn;n++)   {     k=cur;     cur=maxn;     while(k!=1)     {         p=b[k];         while(res[a[p]]!=0&&a[p]+p<maxn)          a[p]+=p;         cur=cur>a[p]?a[p]:cur;         while(k%p==0)  k=k/p;     }     res[cur]=n+1;   }}int main(){   int n;   make_table();   while(scanf("%d",&n)&&n)   {     printf("The number %d appears in location %d.n",n,res[n]);   }   return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/379037.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号