結果

問題 No.648  お や す み 
ユーザー kotamanegi
提出日時 2018-02-09 22:32:23
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,298 bytes
コンパイル時間 1,183 ms
コンパイル使用メモリ 87,312 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-08 15:51:31
合計ジャッジ時間 2,626 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 79 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#define EVAL 1
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
#define PI 3.1415926535
using namespace std;
long long n;
long long solve(long long now){
	if(n > now*(now+1LL)/2LL) return 0;
	return 1;
}
int main(){
	cin >> n;
	long long top = sqrt(4LL*100000000000000000LL) + 1LL;
	long long bot = 0;
	while(top - bot > 1){
		long long mid=(top+bot)/2;
		if(solve(mid) == 0){
			bot = mid;
		}else top = mid;
	}
	if(top*(top+1LL) / 2LL == n){
		cout << "YES" << endl;
		cout << top << endl;
	}else if(bot * (bot+1LL)/2LL == n){
		cout << "YES" << endl;
		cout << bot << endl;
	}else cout << "NO" << endl;
}
0