結果

問題 No.478 一般門松列列
ユーザー fiordfiord
提出日時 2017-02-27 22:06:58
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 1,140 bytes
コンパイル時間 4,739 ms
コンパイル使用メモリ 103,780 KB
実行使用メモリ 23,880 KB
最終ジャッジ日時 2023-09-02 13:15:35
合計ジャッジ時間 9,104 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
21,560 KB
testcase_01 AC 64 ms
21,568 KB
testcase_02 AC 62 ms
23,652 KB
testcase_03 AC 63 ms
19,596 KB
testcase_04 AC 63 ms
21,508 KB
testcase_05 AC 63 ms
21,604 KB
testcase_06 AC 63 ms
21,632 KB
testcase_07 AC 62 ms
21,596 KB
testcase_08 AC 63 ms
21,540 KB
testcase_09 AC 63 ms
23,652 KB
testcase_10 AC 64 ms
23,636 KB
testcase_11 AC 107 ms
21,780 KB
testcase_12 AC 108 ms
21,888 KB
testcase_13 AC 110 ms
23,872 KB
testcase_14 AC 110 ms
21,768 KB
testcase_15 AC 104 ms
21,748 KB
testcase_16 AC 79 ms
23,736 KB
testcase_17 AC 103 ms
19,760 KB
testcase_18 AC 92 ms
21,772 KB
testcase_19 AC 114 ms
23,812 KB
testcase_20 AC 101 ms
23,880 KB
testcase_21 AC 95 ms
21,684 KB
testcase_22 AC 84 ms
19,596 KB
testcase_23 AC 83 ms
21,800 KB
testcase_24 AC 92 ms
21,660 KB
testcase_25 AC 100 ms
21,756 KB
testcase_26 AC 70 ms
21,656 KB
testcase_27 AC 71 ms
23,740 KB
testcase_28 AC 69 ms
21,776 KB
testcase_29 AC 68 ms
21,788 KB
testcase_30 AC 87 ms
21,792 KB
testcase_31 AC 82 ms
23,748 KB
testcase_32 AC 75 ms
21,648 KB
testcase_33 AC 78 ms
21,760 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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

namespace ConsoleApplicationSharp
{
	class Program
	{
		static void Print(List<int> content)
		{
			int n = content.Count();
			for (int i = 0; i < n-1; i++) Console.Write("{0} ", content[i]);
			Console.WriteLine(content[n - 1]);
		}
		static void Main(string[] args)
		{
			int n, k;
			string[] s =Console.ReadLine().Split(' ');
			n = int.Parse(s[0]);    k = int.Parse(s[1]);
			int use = n - k - 2;
			List<int> ret=new List<int>();
			if (use > 0)
			{
				if (use % 2 == 0) ret = new List<int> { 0, 2, 1 };
				else ret = new List<int> { 1, 0, 2 };
				use--;
				int i = 3;
				while (use>0)
				{
					int diff = ret[i - 1] - ret[i - 2];
					if (Math.Abs(diff) == 2)
					{
						ret.Add(ret[i - 1] + (diff > 0 ? -1 : 1));
					}
					else
					{
						ret.Add(ret[i - 1] + (diff > 0 ? -2 : 2));
					}
					use--;	i++;
				}
				for (; i < n; i++)
				{
					ret.Add(2 * ret[i - 1] - ret[i - 2]);
				}
				Print(ret);
			}
			else
			{
				for (int i = 1; i <= n; i++) ret.Add(i);
				Print(ret);
			}
		}
	}
}
0