Prime Land
|
Source : ACM ICPC Central European Regional 1997 |
|
Time limit : 1 sec |
|
Memory limit : 32 M |
Submitted : 238, Accepted : 133
Everybody in the Prime Land is using a prime base number system. In this system, each positive integer x is represented as follows: Let {pi}i=0 denote the increasing sequence of all prime numbers. We know that x > 1 can be represented in only one way in
the form of product of powers of prime factors. This implies that there is an integer kx and uniquely determined integers ekx, ekx-1, ..., e1, e0, (ekx > 0), that x = p(ekx,kx)*p(ekx-1,kx-1)*...*p(e1,1)*p(e0,0). The sequence
(ekx, ekx-1, ... ,e1, e0)
is considered to be the representation of x in prime base number system.
It is really true that all numerical calculations in prime base number system can seem to us a little bit unusual, or even hard. In fact, the children in Prime Land learn to add to subtract numbers several years. On the other hand, multiplication and division
is very simple.
Recently, somebody has returned from a holiday in the Computer Land where small smart things called computers have been used. It has turned out that they could be used to make addition and subtraction in prime base number system much easier. It has been
decided to make an experiment and let a computer to do the operation ``minus one''.
Help people in the Prime Land and write a corresponding program.
For practical reasons we will write here the prime base representation as a sequence of such pi and ei from the prime base representation above for which ei > 0. We will keep decreasing order with regard to pi.
Input
The input consists of lines (at least one) each of which except the last contains prime base representation of just one positive integer greater than 2 and less or equal 32767. All numbers in the line are separated by one space. The last line contains number
0.
Output
The output contains one line for each but the last line of the input. If x is a positive integer contained in a line of the input, the line in the output will contain x - 1 in prime base representation. All numbers in the line are separated by one space. There
is no line in the output corresponding to the last ``null'' line of the input.
Sample Input
17 1
5 1 2 1
509 1 59 1
0
Sample Output
2 4
3 2
13 1 11 1 7 1 5 1 3 1 2 1
题目意思就是给你x的质因数分解,然后求x-1的质因数分解,入门题目~
我的代码:
分享到:
相关推荐
若干百个,没细数,前几个下下来的有良心的回复一下帮我数数。
哈工大hoj1037,详细的源代码,附有注释,可以看懂。
在线OJ网址大全在线OJ网址大全在线OJ网址大全在线OJ网址大全
搭建OJ平台的工具,方便大家搭建自己的OJ,建议大家使用ubuntu14.04版本,比较稳定
OJ习题.zip
这是洛谷OJ题库导出文件,希望大家下载看看
西南科技大学OJ题答案西南科技大学OJ题答案西南科技大学OJ题答案西南科技大学OJ题答案西南科技大学OJ题答案
湖南大学ACM-OJ的部分题目代码,对学习数据结构和算法很有帮助
OJ系统的蓝桥杯题库,http://oj.xpuca.top/,这里有这些题的栗子。
这是聚石塔OJ题库导出文件,希望大家下载看看
HUSTOJ-SAE 安装次数 : 110 本系统为Online Judge 系统,可广泛用于教学、竞赛、招聘等用途。 九度OJ为本系统改造的典型案例。 文档、社区服务见项目首页,http://code.google.com/p/hustoj/ 安装应用 下载应用...
很好的离线题库。。。。。 非常不错北大OJ题目
这是大连东软信息学院的内部OJ题库,希望大家下载看看
oj 的c++类与对象之前包括类与对象的全答案
BJFU-OJ实验
oj题.zip
八中oj代码
华为OJ测试平台的代码集合,可以借鉴代码例子,共同提高。
课程资源 杭电OJ1000-1099答案 ,仅供参考...
OJ基础部分代码 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 ...