結果

問題 No.2449 square_permutation
ユーザー hoppiihoppii
提出日時 2023-09-01 17:40:46
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 742 bytes
コンパイル時間 1,354 ms
コンパイル使用メモリ 67,240 KB
実行使用メモリ 36,940 KB
最終ジャッジ日時 2023-09-01 17:40:54
合計ジャッジ時間 6,894 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
20,696 KB
testcase_01 AC 52 ms
22,792 KB
testcase_02 AC 53 ms
22,688 KB
testcase_03 AC 52 ms
20,732 KB
testcase_04 AC 51 ms
20,776 KB
testcase_05 AC 51 ms
20,780 KB
testcase_06 AC 76 ms
29,616 KB
testcase_07 AC 89 ms
28,104 KB
testcase_08 AC 84 ms
30,352 KB
testcase_09 AC 87 ms
31,016 KB
testcase_10 AC 102 ms
33,136 KB
testcase_11 AC 107 ms
31,668 KB
testcase_12 AC 111 ms
34,200 KB
testcase_13 AC 125 ms
36,584 KB
testcase_14 AC 129 ms
36,676 KB
testcase_15 AC 125 ms
36,656 KB
testcase_16 AC 128 ms
34,800 KB
testcase_17 AC 128 ms
34,780 KB
testcase_18 AC 116 ms
33,688 KB
testcase_19 AC 124 ms
34,540 KB
testcase_20 AC 126 ms
34,808 KB
testcase_21 AC 140 ms
36,692 KB
testcase_22 AC 56 ms
22,772 KB
testcase_23 AC 129 ms
36,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Collections.Generic;
public class Hello{
    public static void Main(){
        // Your code here!
        int n = int.Parse(System.Console.ReadLine());
        int[] ans = new int[n+1];
        for(int i=0;i<n+1;i++) ans[i] = 0;
        for(int i=1;i<n+1;i++){
            
            if(ans[i] != 0) continue;
            List<int> tmp = new List<int>();
            for(int j=1;i*j*j<=n;j++){
                tmp.Add(i*j*j);
            }
            for(int j=0;j<tmp.Count;j++){
                ans[tmp[j]] = tmp[tmp.Count-1-j];
            }
        }
        int[] anss = new int[n];
        for(int i=0;i<n;i++){
            anss[i] = ans[i+1];
        }
        System.Console.WriteLine(string.Join(" ",anss));
    }
}
0