Submission #29317661
Source Code Expand
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
// using mint = modint1000000007;
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,k,n) for (int i = (k); i < (n); ++i)
using namespace std;
using ll = long long;
// using P = pair<ll,ll>;
using P = pair<int,int>;
using vint = vector<int>;
using vll = vector<ll>;
using vvint = vector<vector<int>>;
using vvll = vector<vector<ll>>;
// const ll INF = (ll)2e18+9;
const int INF = (int)2e9+7;
// const ll MOD = (ll)1e9+9;
template<typename T>
void chmin(T &a, T b) { a = min(a, b); }
template<typename T>
void chmax(T &a, T b) { a = max(a, b); }
template<typename T>
void print(vector<T> v) {
int n = v.size();
rep(i,n) {
if (i == 0) cout << v[i];
else cout << ' ' << v[i];
}
cout << endl;
}
map<ll,mint> mp;
mint f(ll x) {
if (0 < x && x <= 3) {
return x;
}
if (mp.count(x)) return mp[x];
mp[x/2] = f(x/2);
mp[(x+1)/2] = f((x+1)/2);
return mp[x] = mp[x/2] * mp[(x+1)/2];
}
void solve() {
ll x;
cin >> x;
cout << f(x).val() << endl;
}
int main() {
solve();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Floor, Ceil - Decomposition |
| User | goropikari |
| Language | C++ (GCC 9.2.1) |
| Score | 300 |
| Code Size | 1317 Byte |
| Status | AC |
| Exec Time | 3 ms |
| Memory | 3652 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt |
| All | 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 02_small_09.txt, 02_small_10.txt, 03_rand_01.txt, 03_rand_02.txt, 03_rand_03.txt, 03_rand_04.txt, 03_rand_05.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01_sample_01.txt | AC | 1 ms | 3596 KiB |
| 01_sample_02.txt | AC | 2 ms | 3500 KiB |
| 01_sample_03.txt | AC | 2 ms | 3592 KiB |
| 02_small_01.txt | AC | 2 ms | 3440 KiB |
| 02_small_02.txt | AC | 3 ms | 3508 KiB |
| 02_small_03.txt | AC | 3 ms | 3604 KiB |
| 02_small_04.txt | AC | 3 ms | 3440 KiB |
| 02_small_05.txt | AC | 2 ms | 3552 KiB |
| 02_small_06.txt | AC | 2 ms | 3652 KiB |
| 02_small_07.txt | AC | 2 ms | 3588 KiB |
| 02_small_08.txt | AC | 2 ms | 3596 KiB |
| 02_small_09.txt | AC | 2 ms | 3500 KiB |
| 02_small_10.txt | AC | 2 ms | 3592 KiB |
| 03_rand_01.txt | AC | 2 ms | 3504 KiB |
| 03_rand_02.txt | AC | 2 ms | 3608 KiB |
| 03_rand_03.txt | AC | 2 ms | 3516 KiB |
| 03_rand_04.txt | AC | 2 ms | 3504 KiB |
| 03_rand_05.txt | AC | 2 ms | 3520 KiB |
| 04_handmade_01.txt | AC | 2 ms | 3440 KiB |
| 04_handmade_02.txt | AC | 3 ms | 3608 KiB |
| 04_handmade_03.txt | AC | 2 ms | 3608 KiB |
| 04_handmade_04.txt | AC | 2 ms | 3632 KiB |