結果

問題 No.648  お や す み 
ユーザー KKT89
提出日時 2020-08-19 17:19:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 1,776 ms
コンパイル使用メモリ 109,556 KB
最終ジャッジ日時 2025-01-13 03:52:06
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 77 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	double n; cin >> n;
	ll nn=n;
	ll m=(sqrt(8*n+1)-1)/2;
	for(ll i=-5;i<=5;i++){
		ll p=m+i;
		if(p%2==0){
			if(p/2*(p+1)==nn){
				printf("YES\n");
				printf("%lld\n",p);
				return 0;
			}
		}
		else{
			if((p+1)/2*p==nn){
				printf("YES\n");
				printf("%lld\n",p);
				return 0;
			}
		}
	}
	printf("NO\n");
}
0