Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Problem : icpc 3053
- // tegs : DP, nnumber theory
- #include <algorithm>
- #include <cstdio>
- #include <deque>
- #include <queue>
- #include <string>
- #include <vector>
- #include <iostream>
- #include <sstream>
- #define pb push_back
- #define mp make_pair
- #define sz(x) ((int)(x.size()))
- #define forn(i,n) for(int i = 0; i < (n); ++i)
- #define update(buf,val) buf = max((buf),val)
- using namespace std;
- stringstream fakestream;
- typedef long long llong;
- typedef unsigned long long ullong;
- typedef vector < int > vi;
- typedef vector < vi > vvi;
- typedef pair <int,int> pi;
- bool getb(int num, int i )
- {
- return (num >> i) & 1;
- }
- int setb(int num, int i )
- {
- return num || (1 << i);
- }
- bool is_contain_substr(const string& sub, int psub, const string& str, int pstr, int& mask)
- {
- if(psub == sz( sub )) return true;
- if(pstr == sz( str )) return false;
- bool ifmiss = is_contain_substr(sub, psub ,str, pstr + 1, mask);
- bool ifget = is_contain_substr(sub, psub+ 1 ,str, pstr + 1, mask);
- if(sub[ psub ] == str[ pstr ] )
- {
- if( ifget )
- mask = setb(mask, pstr);
- return ifmiss || ifget;
- }
- else
- return ifmiss;
- }
- string toString(int a)
- {
- stringstream ss;
- ss << a;
- return ss.str;
- }
- int dp [ mask ]; // len
- int step [ mask ]; // next_step;
- int getVal(int mask)
- {
- string curn;
- for(int i = 0; i < n; ++i)
- if( getb( mask , i) )
- curn.pb( data[ i ]);
- int res = 1e7;
- int n = strtoi( curn );
- int corr_mask = 0;
- for(int d = 2; d * d <= n; ++d)
- {
- if( n % d == 0
- && is_contain_substr( toString( d ), 0, curn, 0, corr_mask))
- {
- for(int i = 0; i < sz><)
- res = min( res, getVal( ));
- }
- }
- }
- int main(){
- #ifdef LOCAL_PROJECT
- //freopen("input","r",stdin);
- #endif
- //freopen("output.txt","w",stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int n;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement