哈理工OJ 1391 Orz odd(规律【没证出来】)
題目鏈接:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1391
Orz odd
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 23(10 users) Total Accepted: 9(8 users) Rating: Special Judge: No
Description
An odd number n ≥ 3 is an “Orz odd” if and only if there exists a permutation of {1,2,…,n} such as {a1,a2,…,an} can make the following n formulas
a1 – a2 + a3 – a4 + … – an – 1 + an
a2 – a3 + a4 – a5 + … – an + a1
……
an – a1 + a2 – a3 + … – an – 2 + an – 1
are all positive.
Please determine if a given number n is an “Orz odd”.
Input
There are multiple test cases. The first line of input is an integer T indicating the number of test cases. Then T test cases follow.
For each test case:
Line 1. This line contains the single integer n (3?≤ n ≤?109).
Output
For each test case:
Line 1. Output “Orz” if n is an “Orz odd”; otherwise output “JiaozhuV5” instead.
Sample Input
2
4
5
Sample Output
JiaozhuV5
Orz
Hint
In the second sample, a permutation of {1,2,3,4,5} is {2,1,3,5,4}.
It can make the following 5 formulas
2 – 1 + 3 – 5 + 4 > 0
1 – 3 + 5 – 4 + 2 > 0
3 – 5 + 4 – 2 + 1 > 0
5 – 4 + 2 – 1 + 3 > 0
4 – 2 + 1 – 3 + 5 > 0
are all positive. So, 5 is an “Orz odd”.
Source
哈理工2012春季校賽 - 現場賽
Author
齊達拉圖@HRBUST
【思路分析】這個題想了很久,證明沒有證明出來為什么,大致的算證出來了,但是寫起來有點麻煩,用STL的next_permiation模擬了一下結果是:n%4=1的時候能使所有式子的結果是整數。
【AC代碼】
總結
以上是生活随笔為你收集整理的哈理工OJ 1391 Orz odd(规律【没证出来】)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python制作二级菜单_Python_
- 下一篇: 使用Python防止SQL注入攻击