POJ1365 Prime Land 初等数论
来源:互联网 发布:聚合数据平台 编辑:程序博客网 时间:2024/06/09 22:48
题目给出x的质数分解,求x-1的质数分解式。
该题对输入的处理比较麻烦。我采用一次性读一行的方法。
#include<stdio.h>#include<string.h>int prime[3000];int e[3000];int main(){char a[1000],b[5],c[5];int u,v,x;while(1){gets(a);sscanf(a,"%d",&u);if(u==0)break;x=1;int len=0;int l=strlen(a); while(1){sscanf(a+len,"%s%s",b,c);sscanf(b,"%d",&u);sscanf(c,"%d",&v);while(v--)x*=u;len+=strlen(b)+2+strlen(c);if(len>l)break;}x--;int tot=0;for(u=2;x>1&&u*u<=x;u++){if(x%u==0){prime[tot]=u;e[tot]=0;do{e[tot]++;x/=u;}while(x%u==0);tot++;}}if(x>1){prime[tot]=x;e[tot++]=1;}for(int i=tot-1;i>0;i--)printf("%d %d ",prime[i],e[i]);printf("%d %d\n",prime[0],e[0]);}return 0;}
0 0
- POJ1365 Prime Land 初等数论
- poj1365 Prime Land
- POJ1365——Prime Land
- POJ1365 Prime Land【质因数分解】【素数】【水题】
- POJ1365——Prime Land(素数筛选加暴力)
- POJ-1365 Prime Land (数论)
- POJ2034 Anti-prime Sequences初等数论
- poj 1365 Prime Land 【简单数论】
- 初等数论
- 初等数论
- 初等数论
- POJ 1365 / Central Europe 1997 Prime Land (数论)
- (Relax 数论1.10)POJ 1365 Prime Land(质因数分解)
- Prime Land
- Prime Land
- Prime Land
- Prime Land
- Prime Land
- 利用FFMPEG+Nginx 搭建 HLS 服务器
- android常用四大绘图类
- 10个可考虑跳槽的信号
- 基于应用抛出事件的 Jobs
- Parcel
- POJ1365 Prime Land 初等数论
- 数据结构之图(存储结构、遍历)
- Unix:第20章 正则表达式
- springMvc3.0.5搭建全程
- 使用NSOperation和NSOperationQueue启动多线程开发应用
- hdu 3299 Distant Galaxy 策略
- 涡街流量计显示值与实际值不符的主要因素
- AC自动机
- C++之练习题38