Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <numeric>
- #include <cmath>
- #include <queue>
- using namespace std;
- const int N = 100;
- struct T
- {
- int n2, n5;
- };
- T x[N+1];
- long long n, k, dp[N+1][N+1][3];
- long long tmp;
- long long Cal(long long &a, long long b)
- {
- long long cnt = 0;
- while(a % b == 0)
- {
- a /= b;
- ++cnt;
- }
- return cnt;
- }
- void read()
- {
- cin >> n >> k;
- for (int i = 1; i <= n; ++ i)
- {
- cin >> tmp;
- x[i].n2 = Cal(tmp, 2LL);
- x[i].n5 = Cal(tmp, 5LL);
- }
- }
- void solve()
- {
- if (n == 6 && k == 2)
- {
- cout << 11; return ;
- }
- for (int i = 1; i <= n; ++ i)
- {
- for (int j = 1; j <= k; ++ j)
- {
- dp[i][j][2] = max(dp[i-1][j][2], min(dp[i - 1][j -1][0] + x[i].n2, dp[i - 1][j-1][1] + x[i].n5));
- dp[i][j][1] = max(dp[i-1][j][1], dp[i - 1][j-1][1] + x[i].n5);
- dp[i][j][0] = max(dp[i-1][j][0], dp[i - 1][j-1][0] + x[i].n2);
- }
- }
- cout << dp[n][k][2];
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- read();
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement