結果
| 問題 |
No.648 お や す み
|
| コンテスト | |
| ユーザー |
hayashi
|
| 提出日時 | 2019-10-28 13:31:05 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 689 bytes |
| コンパイル時間 | 755 ms |
| コンパイル使用メモリ | 109,440 KB |
| 実行使用メモリ | 25,552 KB |
| 最終ジャッジ日時 | 2024-09-14 21:11:31 |
| 合計ジャッジ時間 | 5,137 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 52 RE * 32 |
コンパイルメッセージ
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 static System.Console;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
int N = int.Parse(ReadLine());
//等差数列
//k(k+1)/2 = n
//√k(k+1) = √2n
//√k*k < √k(k+1) = √2n < √(K+1)(k+1)
//k<√2n<k+1
//(long)√2n → k
long a = (long)Math.Sqrt(2 * N);
if(a * (a + 1) / 2 == N)
{
WriteLine("YES");
WriteLine(a);
}
else
{
WriteLine("NO");
}
}
}
}
hayashi