Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define nmax 2005
- #define valmax 3505
- using namespace std;
- ifstream fin ("divmax.in");
- ofstream fout ("divmax.out");
- short int n, x, maxim;
- pair <short int, short int> f[valmax];
- vector <short int> maxdiv;
- int putere( int p)
- {
- int rez = 1;
- while ( p-- )
- rez *= 10;
- return rez;
- }
- bool cmp (int a, int b)
- {
- int ca = a, cb = b, ka = 0, kb = 0;
- while ( ca/=10 )
- ka++;
- while ( cb/=10 )
- kb++;
- while ( a/putere(ka)%10 == b/putere(kb)%10 && ka >= 1 && kb >= 1 )
- {
- ka--;
- kb--;
- }
- return a/putere(ka)%10 > b/putere(kb)%10;
- }
- void ciur( int lim )
- {
- for ( int i = 2; i <= (int)sqrt(lim); ++i )
- if ( !f[i].first )
- {
- f[i].second = i;
- for ( int j = 2*i; j <= lim; j += i )
- f[j] = {1, i};
- }
- }
- int main()
- {
- ios::sync_with_stdio(false);
- cin.tie(NULL); cout.tie(NULL);
- ciur(3500);
- fin>>n;
- for ( int i = 1; i <= n; ++i )
- {
- fin>>x;
- maxdiv.push_back(f[x].second);
- maxim = max(f[x].second, maxim);
- }
- fout<<maxim<<'\n';
- sort(maxdiv.begin(), maxdiv.end(), cmp);
- for ( int i = 0; i < maxdiv.size(); ++i )
- fout<<maxdiv[i];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement