結果
| 問題 |
No.648 お や す み
|
| コンテスト | |
| ユーザー |
tecchaxn
|
| 提出日時 | 2018-02-10 11:21:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 626 bytes |
| コンパイル時間 | 1,333 ms |
| コンパイル使用メモリ | 158,196 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-13 21:06:22 |
| 合計ジャッジ時間 | 3,299 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 84 |
ソースコード
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
#define INF 1e18
#define MOD 1000000007
#define SIZE 100005
using namespace std;
typedef pair<int,int> P;
//-----------------------------------------------------------------------
int calc(int v){
return v*(v+1)/2;
}
signed main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int N; cin>>N;
int r=0;
for(int i=31;i>=0;i--) if(calc(r+(1<<i))<=N) r+=1<<i;
if(calc(r)==N){
cout<<"YES"<<endl;
cout<<r<<endl;
}
else{
cout<<"NO"<<endl;
}
}
tecchaxn