186912025-10-30 22:54:5442Toronyépítés (2,2,3,3)cpp17Accepted 40/401ms508 KiB
#include <iostream>
#include <unordered_map>
using namespace std;

const int mod=20210108;
unordered_map<int,int> d={{0,0},{1,0},{2,2},{3,2},{4,4},{5,8}};

int f(int n){
  if(d.find(n)!=d.end()) return d[n];
  if(n%2==0){
    int cur=(1LL*f(n/2)*f(n/2)+2LL*f(n/2-1)*f(n/2-1)+4LL*f(n/2-2)*f(n/2-1))%mod;
    d[n]=cur;
    return cur;
  }
  int cur=(1LL*f(n/2)*f(n/2+1)+2LL*f(n/2)*f(n/2-1)+2LL*f(n/2-1)*f(n/2-1)+2LL*f(n/2-2)*f(n/2))%mod;
  d[n]=cur;
  return cur;
}

int main() {
  int N;
  cin>>N;
  cout<<f(N)<<"\n";
  return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms320 KiB
8Accepted3/31ms316 KiB
9Accepted3/31ms316 KiB
10Accepted3/31ms508 KiB
11Accepted3/31ms404 KiB
12Accepted3/31ms316 KiB
13Accepted4/41ms316 KiB
14Accepted4/41ms412 KiB
15Accepted2/21ms316 KiB
16Accepted2/21ms316 KiB