結果
| 問題 |
No.1811 EQUIV Ten
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2022-01-14 21:35:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 2,268 bytes |
| コンパイル時間 | 746 ms |
| コンパイル使用メモリ | 74,008 KB |
| 最終ジャッジ日時 | 2025-01-27 11:05:07 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include <vector>
#include <utility>
namespace nachia{
template<unsigned int MOD>
struct StaticModint{
private:
using u64 = unsigned long long;
unsigned int x;
public:
using my_type = StaticModint;
StaticModint() : x(0){}
StaticModint(unsigned int v) : x(v){}
unsigned int operator*() const { return x; }
my_type& operator+=(const my_type& r){ auto t = x + r.x; if(t >= MOD) t -= MOD; x = t; return *this; }
my_type operator+(const my_type& r) const { my_type res = *this; return res += r; }
my_type& operator-=(const my_type& r){ auto t = x + MOD - r.x; if(t >= MOD) t -= MOD; x = t; return *this; }
my_type operator-(const my_type& r) const { my_type res = *this; return res -= r; }
my_type operator-() const { my_type res = *this; res.x = ((res.x == 0) ? 0 : (MOD - res.x)); return res; }
my_type& operator*=(const my_type& r){ x = (u64)x * r.x % MOD; return *this; }
my_type operator*(const my_type& r) const { my_type res = *this; return res *= r; }
my_type pow(unsigned long long i) const {
my_type a = *this, res = 1;
while(i){ if(i & 1) res *= a; a *= a; i >>= 1; }
return res;
}
my_type inv() const { return pow(MOD-2); }
unsigned int val() const { return x; }
static unsigned int get_mod() { return MOD; }
my_type& operator/=(const my_type& r){ return operator*=(r.inv()); }
my_type operator/(const my_type& r) const { return operator/(r.inv()); }
};
}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using i32 = int;
using u32 = unsigned int;
#define rep(i,n) for(int i=0; i<(n); i++)
using m32 = nachia::StaticModint<1000000007>;
int main() {
int N; cin >> N;
m32 dp[16];
dp[0] = 1;
rep(i,N){
m32 tmp[16];
rep(d,16){
tmp[(d*2+1) % 16] += dp[d];
tmp[(d*2) % 16] += dp[d];
}
tmp[10] = 0;
rep(d,16) dp[d] = tmp[d];
}
m32 ans = m32(2).pow(N);
rep(i,16) ans -= dp[i];
cout << *ans << endl;
return 0;
}
struct ios_do_not_sync{
ios_do_not_sync(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
}
} ios_do_not_sync_instance;
Nachia