Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  abc
Language: C/C++
Code:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
unsigned long int rofn(unsigned long int n)
    {
   unsigned long int *x,*y,*z,r,po,*poo;
  
    x=new unsigned long int;
    y=new unsigned long int;
    z=new unsigned long int;
      if((n==0)||(n==1)||(n==2))
                r=1;
            else if(n<=10)
                {if(n<5)
                    r=3;
                 else if(n<7)
                    r=15;
                     else
              r=105;
                             
            }
            else
                {if(n%4!=0)
                {*x=n/4;
                 *x+=1;
                 
                }
                else
                *x=n/4;
                 if(n%5!=0)
                {*y=n/5;
                 *y+=1;
                 
                }
                else
                *y=n/5;
                 
                 if(n%10!=0)
                {*z=n/10;
                 *z+=1;
                 
                }
                else
                *z=n/10;
        po=pow(10,9);   
                 poo=new unsigned long int;
                 *poo=pow(2,*x);
     r=(*poo*rofn(*y)*rofn(*z))%po;
                 
      }
    delete x;
    delete y;
    delete z;
    delete poo;
    return r;
    
}


int main() {unsigned long int r,n,x,y,z[25],x1,x2,po;
            int t,i,j,k;
            cin>>t;
          for(k=0;k<t;k++)
                 {  z[k]=0;
            cin>>n;
           r=rofn(n);
            
           for(i=5;1>=1;i--)
               for(j=1;(j<i)&&((i%j)!=0);j++)
               {
               x=r*i;
            y=r*j;
               x1=pow(x,y);
                   x2=pow(y,x);
                   po=pow(10,9);
               if((x1%po)>(x2%po))
               {if((x1%po)>z[k])
                   z[k]=(x1%po);
               }
               else
                   {if((x2%po)>z[k])
                   z[k]=(x2%po);}
                   
                      
                  
           }
          }
            for(i=0;i<t;i++)
            cout<<z[i];
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    return 0;
}
          
          
          
Comments: