Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define int long long
- #define pb push_back
- #define ll int
- #define S second
- #define F first
- using namespace std;
- const int N=1e3+100;
- const int p[27] = {1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101};
- int a[N][N] ;
- int32_t main ()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- int n;
- cin >> n;
- for (int i=0; i<=n; i++)
- {
- for (int j=0; j<=3; j++)
- {
- if (i==0 ) a[i][j]=1;
- else a[i][j]=0;
- }
- }
- int l=1;
- int r=27;
- int ans=0;
- while (l<=r)
- {
- int mid=(l+r)/2;
- if (p[mid]<=n)
- {
- ans=mid;
- l=mid+1;
- continue;
- }
- else
- {
- r=mid-1;
- }
- }
- cout << p[0] << endl;
- // cout << ans << " " << p[ans] << endl;
- // return 0;
- int k=0;
- for (int i=1; i<=n; i++)
- {
- cout << i << endl;
- for (int j=1; j<=ans; j++)
- {
- k=0;
- int s=1;
- int ma=0;
- while (s<i)
- {
- s=s*p[j];
- if (s>i) break;
- ma = max (a[i-s][j-1], ma);
- k++;
- }
- a[i][j]=max(a[i][j-1],ma) * ma;
- }
- }
- for (int i=0; i<=n; i++)
- {
- for (int j=0; j<=3; j++)
- {
- cout << a[i][j] << " ";
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement