Orange Boy Can You Solve It Out? Ep. 54

Solved!
Difficulty: Div2C

思考题 in dreamland

Construct it

XGN dreamt about the following problem when sleeping:

You are given a positive integer n (2\leq n\leq 10^8). Output an arithmetic expression that yields the value n with the following requirements:

  • The expression should only contain operators "+" "-" and "*"
  • The expression should not have ()s
  • All numbers in the expression are positive integers, coprime with n and are not 1s.
  • The length of the expression should not exceed 500

If n=10, the following expressions satisfy the given conditions:
- 23-13
- 3*7-11

The following don't:
- 11-1 (Usage of 1)
- 25-15 (Does not coprime)
- 39/3-3 (Usage of '/')
- 1+1 (Does not equal to 10)
- 0.5+9.5
- (1+2)*(3+4)

etc.

If there are many answers, print any.

Actually, this problem is so easy that you can add more restrictions like:
- Do not use integers greater than n
- Do not use '*'
- Do not use '-'

etc.

Examples

n=10

Ans=23-13

n=2

Ans=3*5-13

Solution

One possible version: n=(2n+1)-(n+1)

版权声明:
作者:XGN
链接:https://blog.hellholestudios.top/archives/964
来源:Hell Hole Studios Blog
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>
文章目录
关闭
目 录