cpp
#include<iostream>
#include<algorithm>
#include<cmath>
bool dp[100000];
using namespace std;
int n;
int main()
{
cin >> n;
int x = 1;
for (int i = 1;i <= n;i++)
{
if (i == 5 || i == 3)
{
dp[i] = 1;
}
else if(i>5)
{
if (dp[i - 5] || dp[i - 3])
{
dp[i] = 1;
}
}
}
if (dp[n])
{
for (int i = 0;i <= 2000;i++)
{
int t1 = i * 3;
int t2 = n - i * 3;
if (t2 % 5 == 0)
{
cout << i + (t2 / 5) << endl;
return 0;
}
}
}
else
{
cout << "-1" << endl;
}
return 0;
}
cpp
#include<iostream>
#include<algorithm>
#include<cmath>
bool dp[3000010];
using namespace std;
int n;
int main()
{
cin >> n;
int ans = 0;
while (n != 1)
{
if (n % 2 == 0)
{
n /= 2;
ans++;
}
else
{
n--;
ans++;
}
}
cout << ans << endl;
return 0;
}
cpp
#include<iostream>
#include<algorithm>
#include<cmath>
int dp[1000010];
using namespace std;
int n;
int main()
{
cin >> n;
for (int i = 1;i <= n;i++)
{
if (i < 5)
{
dp[i] = i;
}
else if (i < 11)
{
dp[i] = min(dp[i - 1], dp[i - 5]) + 1;
}
else
{
dp[i] = min(dp[i - 1], dp[i - 5]);
dp[i] = min(dp[i], dp[i - 11] )+1;
}
}
cout << dp[n] << endl;
return 0;
}
cpp
#include<iostream>
using namespace std;
int arr[35][35];
int n, m;
int main()
{
cin >> n >> m;
for (int i = 1;i <= n;i++)
{
arr[i][1] = 1;
}
for (int i = 1;i <= m;i++)
{
arr[1][i] = 1;
}
for (int i = 2;i <= n;i++)
{
for (int j = 2;j <= m;j++)
{
if (i % 2 != 0 || j % 2 != 0)
{
arr[i][j] = arr[i - 1][j] + arr[i][j - 1];
}
}
}
cout << arr[n][m];
return 0;
}
cpp
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int n;
double m[110], d[110];
int day[110];
int main()
{
cin >> n;
for (int i = 1;i <= n;i++)
{
cin >> day[i];
}
m[0] = 100;
for (int i = 1;i <= n;i++)
{
m[i] = max(m[i - 1], d[i - 1] / day[i] * 100);
d[i] = max(d[i - 1], m[i - 1] * day[i] / 100);
}
cout <<fixed<<setprecision(2)<<m[n] << endl;
return 0;
}