結果

問題 No.648  お や す み 
ユーザー ats5515
提出日時 2018-02-09 22:43:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 739 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 81,364 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-08 16:37:50
合計ジャッジ時間 2,358 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 69 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	unsigned long long N;
	cin >> N;
	unsigned long long u = (2 * 1000000000ull) + 2;
	unsigned long long d = 0;
	unsigned long long m;
	while (u - d > 1) {
		m = (u + d) / 2;
		if (m*(m + 1) <= 2 * N) {
			d = m;
		}
		else {
			u = m;
		}
	}
	if (N == 1) {
		cout << "YES" << endl;
		cout << 1 << endl;
	}
	else {
		if (m*(m + 1) == 2 * N) {
			cout << "YES" << endl;
			cout << m << endl;
		}
		else {
			cout << "NO" << endl;
		}

	}
}
0