結果

問題 No.648  お や す み 
ユーザー masa
提出日時 2019-02-15 10:27:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 757 ms / 2,000 ms
コード長 580 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 62,340 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-14 05:12:16
合計ジャッジ時間 18,532 ms
ジャッジサーバーID
(参考情報)
judge6 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <array>

using namespace std;
template<class T> int maxReturn(T a, T b) {if (a > b) {return a;} else {return b;}}
template<class T> int minReturn(T a, T b) {if (a < b) {return a;} else {return b;}}

int main(void){
    long long n, i, sheepCount;
    cin >> n;
    i = 1;
    sheepCount = 0;

    while(true) {
    	sheepCount += i;

    	if (sheepCount == n) {
    		cout << "YES" << endl << i << endl;
    		break;
    	}

    	if (sheepCount > n) {
    		cout << "NO" << endl;
    		break;
    	}

    	i++;
    }
}
0