Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: SonnyHappy108
Problemset: อนุกรม
Language: cpp
Time: 0.003 second
Submitted On: 2026-04-14 12:37:23
#include <bits/stdc++.h>
using namespace std;
string addstring(string a, string b) {
string s = "";
int i = a.size() - 1;
int j = b.size() - 1;
int c = 0;
while (i >= 0 || j >= 0 || c) {
int n = c;
if (i >= 0) n += a[i--] - '0';
if (j >= 0) n += b[j--] - '0';
s += (n % 10) + '0';
c = n / 10;
}
reverse(s.begin(), s.end());
return s;
}
int main(){
string a="1",b="1";
int n;
cin >> n;
for(int i=0;i<(n-1)/2;i++){
a=addstring(a,b);
b=addstring(a,b);
}
if(n%2==1){
cout << a;
}
else{
cout << b;
}
}