結果
| 問題 |
No.648 お や す み
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-29 00:33:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 4,893 bytes |
| コンパイル時間 | 3,283 ms |
| コンパイル使用メモリ | 176,928 KB |
| 最終ジャッジ日時 | 2025-01-21 20:22:17 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 84 |
ソースコード
#include <atcoder/all>
#include <bitset>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<ld, ld> pid;
typedef std::pair<ll, std::string> pls;
typedef std::vector<bool> vb;
typedef std::vector<vb> vvb;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::vector<vvi> vvvi;
typedef std::vector<vvvi> vvvvi;
typedef std::vector<ll> vl;
typedef std::vector<vl> vvl;
typedef std::vector<vvl> vvvl;
typedef std::vector<vvvl> vvvvl;
typedef std::vector<ld> vd;
typedef std::vector<vd> vvd;
typedef std::vector<std::string> vs;
#define rep(i,n) for(auto i=0; i<n; ++i)
#define repm(i,s,n) for(auto i=s; i<n; ++i)
#define repd(i,n) for(auto i=n-1; i>=0; --i)
#define repdm(i,e,n) for(auto i=n-1; i>=e; --i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class mint, internal::is_modint_t<mint>* = nullptr> constexpr istream& operator>>(istream& is, mint& x) noexcept {long long v = 0; std::cin >> v; x = v; return is;}
template <class mint, internal::is_modint_t<mint>* = nullptr> constexpr ostream& operator<<(ostream& os, const mint& x) noexcept {os << x.val(); return os;}
inline void _n() { std::cout << std::endl; }
template <class T> inline void _(const T a) { std::cout << a; }
template <class T> inline void _l(const T a) { _(a); _n(); }
template <class T> inline void _s(const T a) { _(a); _(' '); }
template <class T> inline void _v(const std::vector<T> v) { for(auto a : v) _(a); }
template <class T> inline void _vl(const std::vector<T> v) { for(auto a : v) _l(a); }
template <class T> inline void _vs(const std::vector<T> v) { for(auto a : v) _s(a); _n(); }
template <class T> inline void _vvl(const std::vector<std::vector<T>> v) { for(auto a : v) { _v(a); _n(); } }
template <class T> inline void _vvs(const std::vector<std::vector<T>> v) { for(auto a : v) { _vs(a); } }
inline void ynl(const bool b) {_l(b ? "yes" : "no");}
inline void yns(const bool b) {_l(b ? "Yes" : "No");}
inline void ynu(const bool b) {_l(b ? "YES" : "NO");}
constexpr int INF = numeric_limits<int>::max() >> 1;
constexpr long long INF_LL = numeric_limits<long long>::max() >> 1LL;
const long long MOD1 = 1000000007;
const long long MOD9 = 998244353;
using mint1 = atcoder::modint1000000007;
using mint9 = atcoder::modint998244353;
//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//
void input() {
}
template <class Cost> struct graph_m {
public :
graph_m(int n) : _n(n) {
graph = std::vector<std::vector<Cost>> (n, std::vector<Cost>(n, DIST_INF));
dist = std::vector<std::vector<Cost>> (n, std::vector<Cost>(n, DIST_INF));
}
void add (int from, int to, Cost cost){
assert(0 <= from && from < _n);
assert(0 <= to && to < _n);
graph[from][to] = cost;
}
void add_bi (int from, int to, Cost cost){
add(from, to, cost);
add(to, from, cost);
}
Cost get_dist (int from, int to) {
assert(0 <= from && from < _n);
assert(0 <= to && to < _n);
return dist[from][to];
}
std::vector<std::vector<Cost>> get_dists () {
return dist;
}
std::vector<std::vector<Cost>> get_edges () {
return graph;
}
void warshall_floyd () {
dist = graph;
for(int k = 0; k < _n; ++k) {
for(int i = 0; i < _n; ++i) {
for(int j = 0; j < _n; ++j) {
if(dist[i][k] == DIST_INF || dist[k][j] == DIST_INF) continue;
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
}
}
}
private:
int _n;
const Cost DIST_INF = numeric_limits<Cost>::max();
std::vector<std::vector<Cost>> graph;
std::vector<std::vector<Cost>> dist;
};
void solve() {
ll N; cin >> N;
ll tmp = sqrt(2 * N) - 1;
rep(i, 5) {
ll tmp2 = tmp+i;
if(tmp2 * (tmp2+1) / 2 == N) {
_l("YES");
_l(tmp2);
return;
}
}
_l("NO");
}
//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//
int main() {
std::ifstream in("input.txt");
std::cin.rdbuf(in.rdbuf());
std::cin.tie(0);
std::ios::sync_with_stdio(false);
input();
solve();
return 0;
}