Codeforces Beta Round #49 (Div. 2)——C
来源:互联网 发布:手写软件 编辑:程序博客网 时间:2024/05/09 13:49
Once upon a time a little frog whose name was Vasya decided to travel around his home swamp. Overall there are n mounds on the swamp, located on one line. The distance between the neighboring mounds is one meter. Vasya wants to visit all the mounds in one day; besides, he wants to visit each one exactly once. For that he makes a route plan, to decide the order in which to jump on the mounds. Vasya can pick any mound as the first one. He thinks it boring to jump two times at the same distance. That's why he wants any two jumps on his route to have different lengths. Help Vasya the Frog and make the plan for him.
The single line contains a number n (1 ≤ n ≤ 104) which is the number of mounds.
Print n integers pi (1 ≤ pi ≤ n) which are the frog's route plan.
- All the pi's should be mutually different.
- All the |pi–pi + 1|'s should be mutually different (1 ≤ i ≤ n - 1).
If there are several solutions, output any.
思路分析:构造出相邻两个数差不同的序列即可。
#include <cstdio>#include <iostream>using namespace std;int main(){ int n,i; cin>>n; if(n&1) { for(i=1;i<=n/2;i++) cout<<i<<" "<<n-i+1<<" "; cout<<i; } else { for(i=1;i<n/2;i++) cout<<i<<" "<<n-i+1<<" "; cout<<i<<" "<<n-i+1; } return 0;}
- Codeforces Beta Round #49 (Div. 2)——C
- Codeforces Beta Round #16 (Div. 2 Only)——C
- Codeforces Beta Round #18 (Div. 2 Only)——C
- Codeforces Beta Round #34 (Div. 2)——C
- Codeforces Beta Round #74 (Div. 2 Only)——C
- Codeforces Beta Round #49 (Div. 2)—A
- Codeforces Beta Round #31 (Div. 2, Codeforces format)——C
- Codeforces Beta Round #49 (Div. 2) E
- Codeforces Beta Round #65 (Div. 2)——A,B,C
- Codeforces Beta Round #67 (Div. 2)——A,B,C
- Codeforces Beta Round #70 (Div. 2)——A,B,C
- Codeforces Beta Round #72 (Div. 2 Only)——A,B,C
- Codeforces Beta Round #73 (Div. 2 Only)——A,B,C
- Codeforces Beta Round #76 (Div. 2 Only)——A,B,C
- Codeforces Beta Round #77 (Div. 2 Only)——A,B,C
- Codeforces Beta Round #96 (Div. 2)——B
- Codeforces Beta Round #93 (Div. 2 Only)——B
- Codeforces Beta Round #91 (Div. 2 Only)——B
- 作为一个合格程序员该做的事
- Cookie的应用—显示用户上次访问时间
- 友谊-八年级作文
- UVa 409 - Excuses, Excuses!
- linux shellscripts 基本用法
- Codeforces Beta Round #49 (Div. 2)——C
- [转载]c语言中数组作为函数参数
- whats bluesnarfing
- 同步和互斥的一些问题(死锁,优先级逆转)
- Tomcat7和mysql连接池的配置方法和测试(dbcp方式)
- 最简明扼要的美国留学规划方案
- __attribute__机制介绍
- visual studio 2012支持XP了
- 将数据写入到CListCtrl