회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
1
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
16888번 - 루트 게임
lobo_prix
C++20
#define INT64 1 // MLE? #define INTERACTIVE 0 #define COUT_FP_PREC 12 #define TESTCASE #include <bits/stdc++.h> #include <bits/extc++.h> using namespace std; #if !(DEBUG) auto __PRE_RUN__=(ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),(cout << fixed << setprecision(COUT_FP_PREC)),0); #if !(INTERACTIVE) #define endl '\n' // interactive? #endif #endif #if INT64 #define int i64 #endif #define bool char #define pushb push_back #define pushf push_front #define popb pop_back #define popf pop_front #define empl emplace #define emplb emplace_back #define emplf emplace_front #define fi first #define se second #define mkp make_pair #define mkt make_tuple #define cxp constexpr #define PQ std::priority_queue #define lb lower_bound #define ub upper_bound #define reduce accumulate #define func(RetT,fname,...) function<RetT(__VA_ARGS__)> fname=[&](__VA_ARGS__)->RetT #define lam(expr,...) [&](__VA_ARGS__){return expr;} using i64=long long;using u64=unsigned long long;using f64=double; using pint=pair<int,int>;using tint=tuple<int,int,int>; template<class T>using Str=basic_string<T>; template<class T>using PQMax=PQ<T>; template<class T>using PQMin=PQ<T,vector<T>,greater<T>>; template<class T>int sz(const T& x){return x.size();} template<class T>cxp T inf(){return numeric_limits<T>::max()/2;} int divc(int a,int b){return (a+b-1)/b;} int divf(int a,int b){return a/b;} cxp int lg2f(int x){return 63-__builtin_clzll(x);} cxp int lg2c(int x){return 64-__builtin_clzll(x-1);} template<class T>inline T sq(T x){return x*x;} template <class T,class U=T>bool assmin(T& a,U&& b){return a>b?a=b,true:false;} template <class T,class U=T>bool assmax(T& a,U&& b){return a<b?a=b,true:false;} int argmin(const auto& a){return min_element(a.begin(),a.end())-a.begin();} int argmax(const auto& a){return max_element(a.begin(),a.end())-a.begin();} const f64 pi=acosl(-1),eps=1e-10; int dir4[4][2]={{1,0},{0,1},{-1,0},{0,-1}}; int dir8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}}; template<class T>struct Arr : public vector<T>{ Arr():Arr(0){} explicit Arr(int n,T init=T()):vector<T>(n,init){} Arr(initializer_list<T>il):vector<T>(il){} //Arr(vector<T>::iterator s,vector<T>::iterator e):vector<T>(s,e){} T& operator[](int i){ #if DEBUG static bool flag=false; if(!flag && i<0) flag=true,cerr<<"[INFO] Negative Index Found"<<endl; #endif return vector<T>::operator[](i>=0?i:i+this->size()); } const T& operator[](int i)const{return vector<T>::operator[](i>=0?i:i+this->size());} T& at(int i){return *this[i];} const T& at(int i)const{return *this[i];} }; template<class... A> auto ARR(auto n,A&&... a) { if constexpr(!sizeof...(a)) return n; else return Arr(n,ARR(a...)); } static_assert(!INTERACTIVE); struct FIO{ static const int SZ=1<<22; unsigned cnt=0;char a[SZ],*p; FIO(){preload();} int preload(){cin.read(p=a,SZ);return cnt=cin.gcount();} inline char pop(){if(!cnt)preload(); return cnt>0?cnt--,*p++:0;} inline char get(){if(!cnt)preload(); return cnt>0?*p:0;} void ignore_wsc(){while(get()==' '||get()=='\n')pop();} operator bool(){return get();} FIO& operator>>(int& n){ignore_wsc();n=0;char neg=false;if(get()=='-')neg=true,pop();while('0'<=get()&&get()<='9')n=n*10+pop()-'0';if(neg)n*=-1;return *this;} FIO& operator>>(char& c){ignore_wsc();c=pop();return *this;} FIO& operator>>(string& s){ignore_wsc();s.clear();while(get()!=' '&&get()!='\n')s.pushb(pop());return *this;} FIO& operator>>(f64& n){ignore_wsc();string s;while('0'<=get()&&get()<='9'||get()=='.'||get()=='-')s.pushb(pop());n=stod(s);return *this;} }; struct PrettyIO:FIO{ template<class T=int>T tok(){T x;*this>>x;return x;} template<class T=int>Arr<T> toks(int n){Arr<T> a(n);for(auto& i:a)*this>>i;return a;} template<class... A> void _read(A&...a){((*this>>a),...);} }_pcin; #define cin _pcin template<class T> ostream& operator<<(ostream& s,const Arr<T>& a){for(auto i:a)cout<<i<<' ';return s;} #define READ(T,...) T __VA_ARGS__;cin._read(__VA_ARGS__); template<class... A> void PRINT(A...a){((cout<<a<<' '),...,(cout<<endl));} const int N=1000'001; auto dp=ARR(N,(char)false); void solve(){ cout<<(dp[cin.tok()]?"koosaga":"cubelover")<<endl; } signed main() { for(int i=0;i<N;i++) if(!dp[i]) for(int j=1;i+j*j<N;j++) dp[i+j*j]|=true; #ifdef TESTCASE int ti=0,t=cin.tok(); while(++ti<=t) // cout<<"Case #"<<ti<<": ", #endif solve(); }
결과
메모리
시간
코드 길이
맞았습니다!!
7096
32
4393