【2008IO】#ULR 2 A. Goshtasp, Vishtasp and Eidi

A. Goshtasp, Vishtasp and Eidi
time limit per test
5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Goshtasp was known to be a good programmer in his school. One day Vishtasp, Goshtasp's friend, asked him to solve this task:

Given a positive integer n, you should determine whether n is rich.

The positive integer x is rich, if there exists some set of distinct numbers a1, a2, ..., am such that . In addition: every ai should be either a prime number, or equal to 1.

Vishtasp said that he would share his Eidi 50 / 50 with Goshtasp, if he could solve the task. Eidi is money given to children for Noruz by their parents and/or relatives.

Goshtasp needs to solve this problem to get money, you need to solve it to get score!

Input

Input contains a single positive integer n (1 ≤ n ≤ 10000).

Output

If the number is not rich print 0. Otherwise print the numbers a1, ..., am. If several solutions exist print the lexicographically latestsolution. Answers are compared as sequences of numbers, not as strings.

For comparing two sequences a1, ..., am and b1, ..., bn we first find the first index i such that ai ≠ bi, if ai < bi then a is lexicographically earlier and if bi < ai then b is lexicographically earlier. If m ≠ n we add zeroes at the end of the smaller sequence (only for the moment of comparison) and then perform the comparison.

You do not need to minimize the number of elements in sequence (i.e. m). You just need to print the lexicographically latestsolution.

See samples to find out how to print the sequence.

Sample test(s)
input
11
output
11=11
input
545
output
541+3+1=545


又是一场Unknown Language Round……没办法 A题终结者的No.是按照Round编号来的(啊那个加入专栏的不是按Round号而是按照#号顺序的哦~)

强迫症表示,没什么学习意义,不过是也贴一下完成强迫症的心情:


n :=File standardInput readLine asNumber
p :=0
m :=n
while(n>0,for(x,n,1,-1,
q :=0
for(i,2,x-1,if(x%i==0,q :=1;break;))
if(q==0,
if(p==1,"+" print)
p :=1
n :=n-x
x print
break
)
))
"=" print
m println


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

糖果天王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值