結果
| 問題 |
No.478 一般門松列列
|
| コンテスト | |
| ユーザー |
fiord
|
| 提出日時 | 2017-02-27 22:06:58 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 80 ms / 2,000 ms |
| コード長 | 1,140 bytes |
| コンパイル時間 | 2,188 ms |
| コンパイル使用メモリ | 104,960 KB |
| 実行使用メモリ | 20,172 KB |
| 最終ジャッジ日時 | 2024-06-11 19:55:12 |
| 合計ジャッジ時間 | 4,967 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
}
}
}
}
fiord