Advertisement
Zeinab_Hamdy

Untitled

Mar 26th, 2023
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.03 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define ull unsigned ll
  5. #define nl "\n"
  6. #define sz(x) int(x.size())
  7. #define NumOfDigit(w) log10(w) + 1
  8. #define fill(arr, val)  memset(arr, val , sizeof(arr))
  9. #define PI 3.141592654
  10. #define ceil(w, m) (((w) / (m)) + ((w) % (m) ? 1 : 0))
  11. #define all(v) v.begin(), v.end()
  12. #define rall(v) v.rbegin(), v.rend()
  13. #define fi first
  14. #define se second
  15. #define cin(v) for (auto&i:v) cin >> i;
  16. #define cout(v) for (auto&i:v) cout << i << " ";
  17. #define fixed(n) fixed << setprecision(n)
  18. //#define MOD  1e9 + 7
  19.  
  20.  
  21. void IO(){
  22.     ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  23. }
  24. void files(){
  25.     //freopen("filename.in" , "r" ,stdin);
  26.             #ifndef ONLINE_JUDGE
  27.               freopen("input.txt", "r", stdin);  freopen("output.txt", "w", stdout);
  28.             #endif
  29. }
  30. bool prime(ll n){
  31.     if(n==2 || n==3) return true;
  32.     if(n<2 || n%2==0  ) return false;
  33.     for(int i=3;i<=sqrt(n);i+=2)   if(n%i==0) return false;
  34.     return true;
  35. }
  36.  
  37. ll POW(ll a , ll b , ll m){
  38.      ll ans=1;
  39.      while(b){
  40.          if(b&1) ans*=a , ans%=m;
  41.          
  42.          a*=a;
  43.          b/=2;
  44.          a%=m;
  45.      }
  46.      return ans  ;
  47. }
  48.  
  49. void solve(){
  50.  
  51. ll n;
  52. cin >> n ;
  53.  
  54. ll  MO = 998244353;
  55.  
  56.  
  57. vector < pair < ll , ll > >  pr;
  58.  
  59. for(ll i=1 ; i <=sqrtl(n); i++){
  60.     if(n % i ==0){
  61.         pr.push_back( {i , n/i });
  62.     }
  63. }
  64.  
  65. pair < ll , ll > cm = { pr[0].fi , pr[0].se} ;
  66. double temp= 0.0 +pr[0].se * log(pr[0].fi );
  67.  
  68. for(int i=0 ; i < sz(pr) ; i++){
  69.     ll x= pr[i].fi , y = pr[i].se;
  70.     if( x * log(y) > temp){
  71.         temp =x * log(y) ;
  72.        cm.fi=y , cm.se=x;
  73.     }
  74.    
  75.     if( y * log(x) > temp){
  76.         temp =y * log(x) ;
  77.         cm.fi=x  , cm.se=y;
  78.     }
  79.    
  80. }
  81. cout << fixed(0) <<  POW( cm.fi , cm.se , MO)   << nl;
  82.  
  83. }
  84.  
  85. int main(){
  86.                  IO();       //  files();
  87.  
  88.     int testCase=1;  // one test case
  89.     cin >> testCase ;      
  90.  while(testCase--)
  91.         solve();  // my code
  92.        
  93.     return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement