AtCoder Beginner Contest 004

Submission #145654

Source codeソースコード

import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        //Nを標準入力からもらう
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int n = Integer.parseInt(str);

        //カードをつくる
        ArrayList<Integer> card;
        card = new ArrayList<>();

        for (int k = 1; k <= 6; k++) {
            card.add(k);
        }

        //30,60,90...と、Nが30で割り切れるとき、元の並びに戻る
        //ちょっとでも計算量を減らしたいから、Nが大きいときは30で割って、
        //あまりの数だけ並び替えを実行するようにしたい
        if (n > 30) {
            n = n % 30;
        }

        for (int i = 0; i <= n - 1; i++) {

            int mod = i % 5;
            int mod_1 = mod + 1;

            int cardA = card.get(mod);
            int cardB = card.get(mod_1);

            card.set(mod_1, cardA);
            card.set(mod, cardB);

        }

        for (int j = 0; j <= 5; j++) {
            int result = card.get(j);
            System.out.print(result);
        }
        System.out.println();
    }

}

Submission

Task問題 C - 入れ替え
User nameユーザ名 Dahlia*
Created time投稿日時
Language言語 Java (OpenJDK 1.7.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 1260 Byte
File nameファイル名
Exec time実行時間 463 ms
Memory usageメモリ使用量 20092 KB

Test case

Set

Set name Score得点 / Max score Cases
Subtask1 30 / 30 SubTask1/00_sample_00.txt,SubTask1/00_sample_01.txt,SubTask1/00_sample_02.txt,SubTask1/rand_19.txt,SubTask1/rand_2.txt,SubTask1/rand_25.txt,SubTask1/rand_27.txt,SubTask1/rand_33.txt,SubTask1/rand_35.txt,SubTask1/rand_4.txt,SubTask1/rand_44.txt,SubTask1/rand_48.txt,SubTask1/rand_8.txt
Subtask2 70 / 70 SubTask2/00_sample_03.txt,SubTask2/max_case.txt,SubTask2/rand_120009641.txt,SubTask2/rand_134230520.txt,SubTask2/rand_136939465.txt,SubTask2/rand_200732473.txt,SubTask2/rand_211796835.txt,SubTask2/rand_312330341.txt,SubTask2/rand_377341731.txt,SubTask2/rand_384611280.txt,SubTask2/rand_386098102.txt,SubTask2/rand_399010727.txt,SubTask2/rand_409627453.txt,SubTask2/rand_416537730.txt,SubTask2/rand_425486442.txt,SubTask2/rand_493135174.txt,SubTask2/rand_573105326.txt,SubTask2/rand_62794810.txt,SubTask2/rand_649471654.txt,SubTask2/rand_693017484.txt,SubTask2/rand_729197057.txt,SubTask2/rand_759630883.txt,SubTask2/rand_823752210.txt,SubTask2/rand_830399384.txt,SubTask2/rand_893242387.txt,SubTask2/rand_935005824.txt,SubTask2/rand_989703310.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
SubTask1/00_sample_00.txt AC 440 ms 20076 KB
SubTask1/00_sample_01.txt AC 426 ms 20052 KB
SubTask1/00_sample_02.txt AC 416 ms 20084 KB
SubTask1/rand_19.txt AC 413 ms 19956 KB
SubTask1/rand_2.txt AC 429 ms 20076 KB
SubTask1/rand_25.txt AC 425 ms 19952 KB
SubTask1/rand_27.txt AC 419 ms 19960 KB
SubTask1/rand_33.txt AC 419 ms 19960 KB
SubTask1/rand_35.txt AC 423 ms 20080 KB
SubTask1/rand_4.txt AC 424 ms 20076 KB
SubTask1/rand_44.txt AC 422 ms 20076 KB
SubTask1/rand_48.txt AC 411 ms 20012 KB
SubTask1/rand_8.txt AC 423 ms 19948 KB
SubTask2/00_sample_03.txt AC 428 ms 20080 KB
SubTask2/max_case.txt AC 463 ms 19964 KB
SubTask2/rand_120009641.txt AC 418 ms 20084 KB
SubTask2/rand_134230520.txt AC 433 ms 20084 KB
SubTask2/rand_136939465.txt AC 444 ms 19952 KB
SubTask2/rand_200732473.txt AC 431 ms 19964 KB
SubTask2/rand_211796835.txt AC 453 ms 19948 KB
SubTask2/rand_312330341.txt AC 444 ms 19948 KB
SubTask2/rand_377341731.txt AC 440 ms 20088 KB
SubTask2/rand_384611280.txt AC 444 ms 19976 KB
SubTask2/rand_386098102.txt AC 451 ms 20080 KB
SubTask2/rand_399010727.txt AC 436 ms 20080 KB
SubTask2/rand_409627453.txt AC 437 ms 20076 KB
SubTask2/rand_416537730.txt AC 445 ms 19984 KB
SubTask2/rand_425486442.txt AC 450 ms 20092 KB
SubTask2/rand_493135174.txt AC 439 ms 20088 KB
SubTask2/rand_573105326.txt AC 436 ms 19948 KB
SubTask2/rand_62794810.txt AC 447 ms 19948 KB
SubTask2/rand_649471654.txt AC 435 ms 19944 KB
SubTask2/rand_693017484.txt AC 428 ms 20080 KB
SubTask2/rand_729197057.txt AC 438 ms 20076 KB
SubTask2/rand_759630883.txt AC 443 ms 20076 KB
SubTask2/rand_823752210.txt AC 452 ms 20080 KB
SubTask2/rand_830399384.txt AC 437 ms 20072 KB
SubTask2/rand_893242387.txt AC 444 ms 19952 KB
SubTask2/rand_935005824.txt AC 442 ms 20080 KB
SubTask2/rand_989703310.txt AC 426 ms 20060 KB