日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

哈理工OJ 1391 Orz odd(规律【没证出来】)

發布時間:2023/12/10 编程问答 54 豆豆
生活随笔 收集整理的這篇文章主要介紹了 哈理工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代碼】

#include<cstdio> #include<cstring> #include<algorithm> using namespace std;int main() {int t,n;scanf("%d",&t);while(t--){scanf("%d",&n);if(n%4==1)//注意取余只要大于0都為邏輯真{printf("Orz\n");}else{printf("JiaozhuV5\n");}}return 0; }

總結

以上是生活随笔為你收集整理的哈理工OJ 1391 Orz odd(规律【没证出来】)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。