SHARE
TWEET

codeforce - Nirvana

jakaria_hossain Mar 31st, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define fastread()(ios_base:: sync_with_stdio(false),cin.tie(NULL));
  5. int main()
  6. {
  7.     fastread();
  8.     ll n,res;
  9.     cin>>n;
  10.     res=n/10;
  11.     res=res*10-1;
  12.     //cout<<n<<" "<<res<<endl;
  13.     ll x=1,y=1,mx,sub=res;
  14.     while(n>0)
  15.     {
  16.         x*=(n%10);
  17.         n/=10;
  18.     }
  19.     while(res>0)
  20.     {
  21.         y*=(res%10);
  22.         res/=10;
  23.     }
  24.     mx=max(x,y);
  25.     ll i=100;
  26.     while(sub>i)
  27.     {
  28.         res=sub/i;
  29.         res=res*i-1;
  30.         y=1;
  31.         while(res>0)
  32.         {
  33.             y*=(res%10);
  34.             res/=10;
  35.         }
  36.         mx=max(mx,y);
  37.         i*=10;
  38.     }
  39.     cout<<mx<<endl;
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top