結果
| 問題 |
No.648 お や す み
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-02-10 00:06:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,063 bytes |
| コンパイル時間 | 842 ms |
| コンパイル使用メモリ | 82,792 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-13 21:04:45 |
| 合計ジャッジ時間 | 2,878 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 84 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:36:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
36 | scanf("%lld", &n);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>
using namespace std;
#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x) { cout << #x << ": "; \
for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif
typedef pair<int, int> p;
typedef long long int ll;
ll n;
int main(int argc, char *argv[]) {
scanf("%lld", &n);
ll n2 = n * 2;
ll m = sqrt(n2);
for (ll i = m; i >= 0; --i) {
ll v = i * (i + 1);
if (n2 == v)
{
printf("YES\n%lld\n", i);
return 0;
}
if (n2 > v)
{
printf("NO\n");
return 0;
}
}
printf("NO\n");
return 0;
}