设为首页 加入收藏

TOP

ZOJ 3798 Abs Problem
2015-07-20 17:42:47 来源: 作者: 【 】 浏览:2
Tags:ZOJ 3798 Abs Problem


找规律....


Abs Problem

Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge

Alice and Bob is playing a game, and this time the game is all about the absolute value!

Alice has N different positive integers, and each number is not greater than N. Bob has a lot of blank paper, and he is responsible for the calculation things. The rule of game is pretty simple. First, Alice chooses a number a1 from the N integers, and Bob will write it down on the first paper, that's b1. Then in the following kth rounds, Alice will choose a number ak (2 ≤ k ≤ N), then Bob will write the number bk=|ak-bk-1| on the kth paper. |x| means the absolute value of x.

Now Alice and Bob want to kown, what is the maximum and minimum value of bN. And you should tell them how to achieve that!

Input

The input consists of multiple test cases;

For each test case, the first line consists one integer N, the number of integers Alice have. (1 ≤ N ≤ 50000)

Output

For each test case, firstly print one line containing two numbers, the first one is the minimum value, and the second is the maximum value.

Then print one line containing N numbers, the order of integers that Alice should choose to achieve the minimum value. Then print one line containing N numbers, the order of integers that Alice should choose to achieve the maximum value.

Attention: Alice won't choose a integer more than twice.

Sample Input

2

Sample Output

1 1
1 2
2 1

Author: ZHANG, Ruixiang
Source: ZOJ Monthly, August 2014



#include 
  
   
#include 
   
     #include 
    
      #include 
     
       using namespace std; int n; int main() { while(scanf("%d",&n)!=EOF) { if(n==1) { puts("1 1"); puts("1 1"); puts("1 1"); continue; } if(n==2) { puts("1 1"); puts("1 2"); puts("2 1"); continue; } int b1=n,b2=n-1; for(int i=2;i<=n;i++) { b1=abs(b1-(n-i+1)); } for(int i=2;i
      
       




】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇重定向对标准IO缓冲的影响 下一篇HDU 1811-Rank of Tetris(拓扑排..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·工业机器人TCP校准中 (2025-12-25 05:19:17)
·opc 通讯协议与 TCP (2025-12-25 05:19:15)
·labview中tcp/ip通信 (2025-12-25 05:19:13)
·新书介绍《Python数 (2025-12-25 04:49:47)
·怎么利用 Python 进 (2025-12-25 04:49:45)