結果
問題 | No.1310 量子アニーリング |
ユーザー | sapphire__15 |
提出日時 | 2020-12-07 16:55:17 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,290 bytes |
コンパイル時間 | 1,276 ms |
コンパイル使用メモリ | 119,084 KB |
実行使用メモリ | 7,128 KB |
最終ジャッジ日時 | 2024-09-17 13:56:18 |
合計ジャッジ時間 | 2,600 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 4 ms
6,940 KB |
testcase_06 | WA | - |
testcase_07 | AC | 3 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 3 ms
6,944 KB |
testcase_10 | WA | - |
testcase_11 | AC | 3 ms
6,944 KB |
testcase_12 | AC | 3 ms
6,944 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | RE | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | RE | - |
testcase_23 | WA | - |
ソースコード
#include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <bitset> #include <climits> #include <cmath> #include <bitset> #include <complex> #include <functional> #include <cmath> #include <cassert> #include <stack> typedef long long ll; typedef std::pair<int, int> Pii; typedef std::pair<long long, long long> Pll; typedef std::pair<double, double> Pdd; #define rip(i, n, ss) for (int i = (ss);i < (int)( n ); i++) #define all(l) l.begin(), l.end() #define MM << " " << template<typename T> using MaxHeap = std::priority_queue<T>; template<typename T> using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>; template<typename T> inline bool chmax(T &l, const T b) { if (l < b) { l = b; return true; } return false; } template<typename T> inline bool chmin(T &l, const T b) { if (l > b) { l = b; return true; } return false; } # ifdef LOCAL_DEBUG template<typename T> void vdeb(const std::vector<T> &bb) { for (unsigned int i = 0;i < bb.size();i++) { if (i == bb.size() - 1) std::cout << bb[i]; else std::cout << bb[i] << ' '; } std::cout << '\n'; } template<typename T> void vdeb(const std::vector<std::vector<T>> &bb) { for (unsigned int i = 0;i < bb.size();i++) { std::cout << i << ' '; vdeb(bb[i]); } std::cout << '\n'; } # endif long long pow(long long n, long long p, long long k) {//n^k(mod p) if (!k) return 1; long long a = pow(n,p, k>>1); a = a * a%p; if (k & 1) a = a * n%p; return a; } void euclid(long long &a, long long &b, long long p) { // a>=b A*b+B*(a-a/b*b)=1 if (a == 1) { a = 1; } else { long long A = b, B = a % b; euclid(A, B, p); b = (A - (p + a / b) % p * B % p + p) % p; a = B; } } long long rev(long long n, long long p) {// n*x-p*y=1 //long long q = p; //euclid(p, n, p); //return n % q; return pow(n,p,p-2); } long long bino(long long n, long long m, long long p) {//nCm(mod p) long long ans = 1, div = 1; for(int i = 0;i < m; i++){ ans = (n - i) * ans % p; div = div * (i +1) % p; } return ans * rev(div, p) % p; } struct modint { long long num; long long p; modint() { num = 0; p = 998244353; } modint(long long x) { p = 998244353; num = x % p; } modint inv()const{return rev(num, p);} modint operator-() const{return modint(p-num);} modint& operator+=(const modint &other){ num = (num + other.num) % p; return *this; } modint& operator-=(const modint &other){ num = (num - other.num + p) % p; return *this; } modint& operator*=(const modint &other){ num = (num * other.num) % p; return *this; } modint& operator/=(const modint &other){ (*this) *= other.inv(); return *this; } modint& operator+=(const long long &other){ num = (num + other) % p; return *this; } modint& operator-=(const long long &other){ num = (num - other + p) % p; return *this; } modint& operator*=(const long long &other){ num = (num * other) % p; return *this; } modint& operator/=(const long long &other){ (*this) *= rev(other, p); return *this; } modint& operator++(){return *this += 1;} modint& operator--(){return *this -= 1;} modint& operator=(const long long &other){return (*this) = modint(other);} modint operator+(const modint &other) const{return modint(*this) += other;} modint operator-(const modint &other) const{return modint(*this) -= other;} modint operator*(const modint &other) const{return modint(*this) *= other;} modint operator/(const modint &other) const{return modint(*this) /= other;} modint operator+(const long long &other) const{return modint(*this) += other;} modint operator-(const long long &other) const{return modint(*this) -= other;} modint operator*(const long long &other) const{return modint(*this) *= other;} modint operator/(const long long &other) const{return modint(*this) /= other;} bool operator==(const modint &other) const{return num == other.num;} }; std::istream& operator>>(std::istream &is, const modint x) { std::cin >> x.num; return is; } std::ostream& operator<<(std::ostream &os, const modint &x){ std::cout << x.num; return os; } struct combination{ std::vector<modint> li; std::vector<modint> rev; combination(int size){ li = std::vector<modint>(size); rev = std::vector<modint>(size); li[0] = 1; for(int i= 1; i< size;i++) li[i] = li[i-1]*i; rev.back() = modint(1)/li.back(); for(int i = size-1; i > 0; i--) rev[i-1] = rev[i]*i; } modint nCk(int n, int k){ if(k <= 0 || n <= k) return 1; return li[n]*rev[k]*rev[n-k]; } } comb(20200); using namespace std; int main() { int n; cin >> n; vector<modint> da(n+1); da[0] += 1; rip(i,n,0) { da[i+1] = da[i] * 2; } modint ans; rip(i,n+1,0) { int j = n-i; ans += comb.nCk(n, i) * da[abs(i-j)]; } cout << ans << endl; }