結果

問題 No.1500 Super Knight
ユーザー sirogamichan1sirogamichan1
提出日時 2021-04-23 15:37:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 5,535 bytes
コンパイル時間 5,487 ms
コンパイル使用メモリ 370,096 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-04 07:07:28
合計ジャッジ時間 6,271 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;

//////////////////////////////
// Check before you submit.
//#define _ATCODER_LIBRARY

const long long MOD = 1e9+7;
// const long long MOD = 998244353;

/////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;

#ifdef _ATCODER_LIBRARY
using namespace atcoder;
#endif
// _ATCODER_LIBRARY

const long long INF = 1LL << 60;
const double PI = acos(-1);
using ll = long long;
using P = array<ll, 2>;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SUM(v) accumulate(ALL(v),0ll)

template<typename T>istream& operator>>(istream&i,vector<T>&v){REP(j,v.size())i>>v[j];return i;}
template<typename T>string join(vector<T>&v){stringstream s;REP(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v){if(v.size())o<<join(v);return o;}
template<typename T>string join(vector<vector<T>>&vv){string s="\n";REP(i,vv.size())s+=join(vv[i])+"\n";return s;}
template<typename T>ostream& operator<<(ostream&o,vector<vector<T>>&vv){if(vv.size())o<<join(vv);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v){return o<<"("<<v.first<<","<<v.second<<")";}
template<typename T>istream& operator>>(istream&i,array<T,2>&v){i>>v[0]>>v[1]; return i;}
template<typename T>ostream& operator<<(ostream&o,array<T,2>&v){return o<<"("<<v[0]<<","<<v[1]<<")"; return o;}

#define DEBUG(x);

#ifdef _DEBUG
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
#define GLIBCXX_DEBUG
#define GLIBCXX_DEBUG_PEDANTIC
#endif
// _DEBUG

int dx[4]{0, 1, 0, -1};
int dy[4]{1, 0, -1, 0};

void init_init_init() {ios_base::sync_with_stdio(false);cin.tie(NULL);std::cout<<fixed<<setprecision(10);}
template<class T>T up(T a, T b){assert(b);return (a+b-1)/b;}
template<typename... A>bool eq(A const&... a){auto t={a...};assert(t.size());auto tar=*t.begin();for(const auto&e:t)if(tar!=e)return false;return true;}
template<typename T,typename ...Args>auto make_vector(T x,int arg,Args ...args){if constexpr(sizeof...(args)==0)return vector<T>(arg,x);else return vector(arg,make_vector<T>(x,args...));}

template<class T>bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T>bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmax(T &a, initializer_list<T>l){return chmax(a,max(l));}
template<class T>bool chmin(T &a, initializer_list<T>l){return chmin(a,min(l));}

//////////////////////////////////////////////////////////////////
// My Library
//////////////////////////////////////////////////////////////////

template<int mod> struct Fp {
    long long val;
	
    constexpr Fp(long long v = 0) noexcept : val(v % mod) {
        if (val < 0) val += mod;
    }
	static long long inv(long long a, long long m)
	{
		long long b = m, u = 1, v = 0;
		while (b)
		{
			long long t = a/b;
			a -= t*b; swap(a, b);
			u -= t*v; swap(u, v);
		}
		if (u<0)u+=m;
		return u;
	}
    constexpr int getmod() { return mod; }
    constexpr Fp operator - () const noexcept {
        return val ? mod - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= mod) val -= mod;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += mod;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % mod;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        val = val * Fp<mod>::inv(r.val, mod) % mod;
        if (val < 0) val += mod;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<mod>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<mod> modpow(const Fp<mod> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
	friend constexpr Fp<mod> modfac(long long l, long long r) noexcept
	{
		auto res = Fp<mod>(1);
		for (Fp<mod> i = l; i < r; ++i) res *= i;
		return res;
	}
};
using mint = Fp<MOD>;


//////////////////////////////////////////////////////////////////
// Contest Code
//////////////////////////////////////////////////////////////////


mint solve(ll N)
{
	mint n = (mint)N;

	mint res;
	if (n == 0)
			res = 1;
	else if (n == 1)
			res = 12;
	else if (n == 2)
			res = 65;
	else
			res = n*n*17 + n*6 + 1;

	return res;
}

int main(int argc, char **argv)
{
	init_init_init();

	ll N; cin >> N;
	assert(0 <= N and N <= 1e9);
	std::cout << solve(N) << std::endl;
}
0