結果

問題 No.648  お や す み 
ユーザー makonagix
提出日時 2018-02-16 11:36:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1,508 ms / 2,000 ms
コード長 592 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 61,336 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-13 21:12:53
合計ジャッジ時間 34,415 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

#define rep0(n) for(int i=0;i<n;i++)
#define rep(n) for(int i=1;i<=n;i++)

double const pi=3.1415926535;
int const mod=1000000007;
int const inf=2147483647;

int printint(int n){
	cout<<n<<endl;
	return 0;
}

int prints(string s){
	cout<<s<<endl;
	return 0;
}

int main(){
	long long n;
	cin>>n;
	long long value=0;
	int i=1;
	while(n>value){
		value+=i;
		if(n==value){
			cout<<"YES"<<endl;
			cout<<i<<endl;
			return 0;
		}
		else if(value>n){
			cout<<"NO"<<endl;
			return 0;
		}
		i++;
	}
}
0