結果
| 問題 |
No.648 お や す み
|
| コンテスト | |
| ユーザー |
ats5515
|
| 提出日時 | 2018-02-09 22:37:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 739 bytes |
| コンパイル時間 | 1,171 ms |
| コンパイル使用メモリ | 80,136 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-08 16:10:13 |
| 合計ジャッジ時間 | 3,431 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 69 WA * 15 |
ソースコード
#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;
}
}
}
ats5515