🛶Hint:记忆化递归|大整数加法模拟|……待更新
⛵️偷偷制造
🌋打赏偷偷:[置顶]⬆️修考使用必看🔥
#include<bits/stdc++.h>
using namespace std;
const int M = 1000;
bool vis[M];
long long dp[M];
const int limit = 32;
int f(int x){
if(x <= 2) return 1;
return f(x - 1) + f(x - 2);
}
void solve1(){
cout << f(10) << endl;
}
long long fp(int x){
if(vis[x]) return dp[x];
vis[x] = true;
if(x <= 2) return dp[x] = 1;
return dp[x] = fp(x - 1) + fp(x - 2);
}
void solve2(){
cout << fp(50) << endl;
}
struct Bigint{
int num[limit];
Bigint(){
for(int i = 0; i < limit; i++) num[i] = 0;
}
friend Bigint operator + (Bigint f1, Bigint f2){
Bigint ans;
for(int i = 0; i < limit; i++){
ans.num[i] = f1.num[i] + f2.num[i];
}
for(int i = 0; i < limit; i++){
int carry = ans.num[i] / 10;
ans.num[i] %= 10;
if(i + 1 < limit) ans.num[i + 1] += carry;
}
return ans;
}
void print(){
for(int i = limit - 1; i >= 0; i--) cout << num[i];
cout << endl;
}
};
Bigint get(string s){
Bigint ans;
reverse(s.begin(), s.end());
for(int i = 0; i < limit && i < s.size(); i++){
ans.num[i] = s[i] - '0';
}
return ans;
}
void solve3(){
string s1 = "00123456789012345678901234567890";
string s2 = "00987654321098765432109876543210";
Bigint a = get(s1);
Bigint b = get(s2);
Bigint ans = a + b;
ans.print();
}
int main(){
// solve1();
// solve2();
// solve3();
}