zoukankan      html  css  js  c++  java
  • Codeforces Beta Round #49 (Div. 2)-C. Little Frog

    C. Little Frog
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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.

    Input

    The single line contains a number n (1 ≤ n ≤ 104) which is the number of mounds.

    Output

    Print n integers pi (1 ≤ pi ≤ n) which are the frog's route plan.

    • All the pi's should be mutually different.
    • All the |pipi + 1|'s should be mutually different (1 ≤ i ≤ n - 1).

    If there are several solutions, output any.

    Sample test(s)
    input
    2
    output
    1 2 
    input
    3
    output
    1 3 2 
    水题:只需前后交替输出
     1 /******************************
     2 AC
     3 date£º2013-10-9-17:00
     4 *********************************/
     5 
     6 
     7 #include <iostream>
     8 #include<stdio.h>
     9 #include<string.h>
    10 #include<math.h>
    11 
    12 using namespace std;
    13 
    14 int main()
    15 {
    16     int n;
    17     scanf("%d",&n);
    18     int i;
    19     for(i=1;i<=n/2;i++)
    20     {
    21         if(i==(int)(n/2))
    22         printf("%d %d",i,n-i+1);
    23         else
    24         printf("%d %d ",i,n-i+1);
    25     }
    26     if(n%2==0)
    27     printf("
    ");
    28     else if(n==1)
    29     printf("1
    ");
    30     else
    31     printf(" %d
    ",n/2+1);
    32     return 0;
    33 }
    View Code


  • 相关阅读:
    框架学习之Struts2 第五节 自定义拦截器
    框架学习之Struts2 第四节 文件上传
    2011_7_23 第三次评审
    框架学习之Struts2 第二节 Action的详解
    框架学习之Struts2 第一节 开发环境的搭建和第一个应用开发
    框架学习之Struts2 第七节 国际化
    关于LookUp的总结
    UML自学手册___事务模式——事务与人、地、物
    css合并外边距详解
    开发中的函数相关
  • 原文地址:https://www.cnblogs.com/ACshasow/p/3362106.html
Copyright © 2011-2022 走看看