結果

問題 No.648  お や す み 
ユーザー kotatsugame
提出日時 2018-02-10 00:55:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 256 bytes
コンパイル時間 818 ms
コンパイル使用メモリ 65,192 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-09 09:09:10
合計ジャッジ時間 2,514 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 79 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
long n,f,l;
main()
{
	cin>>n;l=n;
	for(int i=0;i<99;i++)
	{
		long m=f+l>>1;
		if(m*(m+1)/2<0)l=m;
		else if(m*(m+1)/2<n)f=m;
		else l=m;
	}
	if(l*(l+1)/2==n)
	{
		cout<<"YES\n"<<l<<endl;
	}
	else cout<<"NO"<<endl;
}
0