結果

問題 No.1519 Diversity
ユーザー bluemegane
提出日時 2021-05-29 07:22:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 777 bytes
コンパイル時間 4,848 ms
コンパイル使用メモリ 110,724 KB
実行使用メモリ 34,492 KB
最終ジャッジ日時 2024-11-07 17:43:29
合計ジャッジ時間 3,087 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int a { get; set; }
    public int b { get; set; }
}

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        getAns(n);
    }
    static void getAns(int n)
    {
        var ps = new List<P>();
        var imax = n / 2;
        var jmax = n;
        for (int i = 1; i <= imax; i++)
        {
            for (int j = i + 1; j <= jmax; j++) ps.Add(new P { a = i, b = j });
            jmax--;
        }
        Console.WriteLine(ps.Count());
        var sb = new StringBuilder();
        foreach (var x in ps)
            sb.Append(string.Format("{0} {1}\n", x.a, x.b));
        Console.Write(sb);
    }
}
0