Added my works from 2022
This commit is contained in:
15
alg_4_5.cpp
Normal file
15
alg_4_5.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int f(int n)
|
||||
{
|
||||
if (n == 1) { return 1; }
|
||||
if (n % 2 == 0) { return f(n / 2); }
|
||||
return f((n - 1) / 2) + f((n - 1) / 2 + 1);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int n; cin >> n;
|
||||
cout << f(n);
|
||||
}
|
||||
Reference in New Issue
Block a user