結果
| 問題 |
No.648 お や す み
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-19 17:23:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 943 bytes |
| コンパイル時間 | 1,671 ms |
| コンパイル使用メモリ | 109,908 KB |
| 最終ジャッジ日時 | 2025-01-13 03:52:48 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 84 |
ソースコード
//#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);
ll nn; cin >> nn;
double n=nn;
ll m=(sqrt(8*n+1)-1)/2;
for(ll i=-5;i<=5;i++){
ll p=m+i;
if(p<0)continue;
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");
}