A. Exam

感觉那么投机取巧
这个都可以

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;



public class A534 {

    public static void solve(){
        Scanner in=new Scanner(System.in);
        PrintStream out=System.out;
        int n=in.nextInt();
        if(n==2){
            out.println("1");
            out.println("1");
        }else if(n==3){
            out.println("2");
            out.println("1 3");
        }else{
            out.println(n);
            for(int i=2;i<=n;i=i+2){
                out.print(i+" ");
            }
            for(int i=1;i<=n;i=i+2){
                out.print(i+" ");
            }
        }
    }
        public static void solve1(){
            Scanner in=new Scanner(System.in);
            PrintStream out=System.out;
            int n=in.nextInt();
            if(n==2){
                out.println("1");
                out.println("1");
            }else if(n==3){
                out.println("2");
                out.println("1 3");
            }else{
                out.println(n);
                ArrayList al = new ArrayList();
                for(int i=2;i<=n;i=i+2){
                    al.add(i);
                }
                for(int i=1;i<=n;i=i+2){
                    al.add(i);
                }
                for(Object i : al){
                    out.print(i+" ");
                }
            }
    }
    public static void main(String [] args){
// new A534().solve();
        new A534().solve1();
    }
}

你可能感兴趣的:(java,codeforces)