結果

問題 No.1585 Cubic Number
ユーザー YoureinYourein
提出日時 2022-02-04 13:17:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 7,644 bytes
コンパイル時間 5,441 ms
コンパイル使用メモリ 154,944 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 03:32:07
合計ジャッジ時間 4,919 ms
ジャッジサーバーID
(参考情報)
judge16 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>

//Binary Indexed Tree
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
//Binary Indexed Tree

using namespace std;
using ll = long long;
using ld = long double;

#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

//Vector in
template <typename T> istream &operator>>(istream &is, vector<T> &x){
    for (auto &y:x) is >> y; 
    return is;
}
//Vector in

//Vector out
template <typename T> ostream &operator<<(ostream &os, vector<T> &x){
    for (long long e = 0; e < (int)x.size(); e++){
        if (e == (int)x.size()-1) os << x[e];
        else os << x[e] << " ";
    }
    return os;
}
//Vector out

namespace cpio{
    //IO library for Competitive-Programming
    struct scanner {
        private:
            struct reader {
                template <typename T> operator T() const {T buf; std::cin >> buf; return buf;}
            };
        public:
            scanner() {std::cin.sync_with_stdio(false); std::cin.tie(nullptr);}

            reader operator()() const {return reader();}
    };

    //Debug out
    void dout(){
        cerr << "\n";
    }
    template<typename T, typename... Ts>
    void dout(const T& a, const Ts&... b){
        cerr << a;
        (cerr << ... << (cerr << ' ', b));
        cerr << "\n";
    }

    template<typename... T>
    void input(T&... a){
        (cin >> ... >> a);
    }
}

namespace cpmath{
    //Math library for Competitive-Programming
    const ll mod97 = 1000000007;
    const ll mod99 = 1000000009;
    const ll mod89 = 998244353;
    const long double pi = 3.14159265359;
    std::unordered_set<long long> allowed_mod;
    std::unordered_set<long long> unallowed_mod;

    constexpr int DX4[4] = {1, 0, -1, 0};
    constexpr int DY4[4] = {0, 1, 0, -1};
    constexpr int DX8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
    constexpr int DY8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

    ll factorial(ll a, ll b = -1, const ll fmod = -1){
        ll ans = 1;
        if (fmod > 1) {
            if (b == -1) for (ll i = a; i > 1; i--) ans = ((ans%fmod)*(i%fmod))%fmod;
            else for (ll i = a; i >= b; i--) ans = ((ans%fmod)*(i%fmod))%fmod;
        }
        else{
            if (b == -1) for (ll i = a; i > 1; i--) ans = ans*i;
            else for(ll i = a; i >= b; i--) ans = ans*i;
        }
        return ans;
    }

    ll fastpow(ll m, ll p){
        if (p == 0) return 1;
        if (p%2 == 0){
            ll t = fastpow(m, p/2);
            return t*t;
        }
        return m*fastpow(m, p-1);
    }

    ll modpow(ll m, ll p, const ll fmod){
        if (p == 0) return 1;
        if (p%2 == 0){
            ll t = modpow(m, p/2, fmod);
            return (t*t)%fmod;
        }
        return (m*modpow(m, p-1, fmod))%fmod;
    }

    ld dtor(const ld deg){return deg*(pi/(ld)180);}

    template <typename T = long long>
    class modint{
    private:
        T num;
        long long mod;
        bool set_prime_flag;
    public:
        explicit modint(T n, long long m = cpmath::mod99, bool pflag = true){
            num = static_cast<T>(n);
            set_prime_flag = pflag;
            
            if (pflag == true){
                if (mod_is_prime(m)) mod = m;
                else throw std::invalid_argument("Invalid value for mod: Check mod is prime number or set plag to false");
            }
            else mod = m;
        } //modint constructer

        //+ operator
        constexpr modint operator+(modint &t){return modint((this->raw()+t.raw())%this->mod, this->mod, this->set_prime_flag);}
        constexpr modint operator+(long long t){return modint((this->raw()+t)%this->mod, this->mod, this->set_prime_flag);}
        constexpr modint operator+=(modint &t){
            this->num = (this->raw()+t.raw())%mod;
            return modint(this->num, mod, set_prime_flag);
        }
        constexpr modint operator+=(long long t){
            this->num = (this->raw()+t)%mod;
            return modint(this->num, mod, set_prime_flag);
        }
        //+ operator
        //- operator
        constexpr modint operator-(modint &t){return modint(((this->raw()-t.raw())%this->mod+this->mod)%this->mod, this->mod, this->set_prime_flag);}
        constexpr modint operator-(long long t){return modint(((this->raw()-t)%this->mod+this->mod)%this->mod, this->mod, this->set_prime_flag);}
        constexpr modint operator-=(modint &t){
            this->num = ((this->raw()-t.raw())%this->mod+this->mod)%this->mod;
            return modint(this->num, this->mod, this->set_prime_flag);
        }
        constexpr modint operator-=(long long t){
            this->num = ((this->raw()+t)%this->mod+this->mod)%this->mod;
            return modint(this->num, mod, this->set_prime_flag);
        }
        //- operator
        //* operator
        constexpr modint operator*(modint &t){return modint((this->raw()*t.raw())%this->mod, this->mod, this->set_prime_flag);}
        constexpr modint operator*(long long t){return modint((this->raw()*(t%mod))%this->mod, this->mod, this->set_prime_flag);}
        constexpr modint operator*= (modint &t){
            this->num = (this->raw()*t.raw())%this->mod;
            return modint(this->num, this->mod, this->set_prime_flag);
        }
        constexpr modint operator*=(long long t){
            this->num = (this->raw()*(t%mod))%mod;
            return modint(this->num, this->mod, this->set_prime_flag);
        }
        //* operator

        //= operator
        constexpr modint operator=(long long t){
            this->num = t%mod;
            return modint(this->num, this->mod, this->set_prime_flag);
        }
        //= operator

        void plus(T n){num = (num+(n%mod))%mod;}
        void minus(T n){num = ((num-(n%mod))%mod+mod)%mod;}
        void multi(T n){num = ((num%mod)*(n%mod))%mod;}
        void div(T n){
            if (set_prime_flag == false) throw std::logic_error("Not Divisible in case you don't set pflag true");
            else num = (num*inversed(n))%mod;
        }
        
        T raw(){return num;}
    private:
        long long inversed(ll n){
            return cpmath::modpow(n, mod-2, mod);
        }

        bool mod_is_prime(int n){
            if (n == cpmath::mod97 || n == cpmath::mod99 || n == cpmath::mod89 || cpmath::allowed_mod.count(n) > 0){
                return true;
            }
            else if (cpmath::unallowed_mod.count(n) > 0){
                return false;
            }
            else{
                for (ll i = 2; i*i <= n; i++){
                    if (n%i == 0) {
                        cpmath::unallowed_mod.insert(n);
                        return false;
                    }
                }
                cpmath::allowed_mod.insert(n);
                return true;
            }
        } //mod_is_prime
    }; //modint
}

cpio::scanner in;
using cpio::dout;
using cpio::input;
using cpmath::mod89;
using cpmath::mod97;
using cpmath::mod99;
using cpmath::modint;
//using cpmath::DX4;
//using cpmath::DY4;
//using cpmath::DX8;
//using cpmath::DY8;

//GNU Binary Indexed Tree
// template<typename T>
// using gtree = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main(){
    ll n = in();

    for (ll i = 0; i <= 1000000LL; i++){
        if (i*i*i == n){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}
0