Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.math.BigInteger;
- import java.util.*;
- /* I S H M A M
- R U H A N
- */
- public class Main {
- //Fastest I/O Class Start
- static class FastReader{
- BufferedReader br;
- StringTokenizer st;
- public FastReader(){
- br=new BufferedReader(new InputStreamReader(System.in));
- }
- String next(){
- while(st==null || !st.hasMoreElements()){
- try{
- st=new StringTokenizer(br.readLine());
- }catch(Exception e){
- }
- }
- return st.nextToken();
- }
- int nextInt(){
- return Integer.parseInt(next());
- }
- long nextLong(){
- return Long.parseLong(next());
- }
- double nextDouble(){
- return Double.parseDouble(next());
- }
- String nextLine(){
- String str="";
- try{
- str=br.readLine();
- }catch(Exception e){
- }
- return str;
- }
- }
- //Fastest I/O Class End
- //Super Fast I/O class Start
- static class Reader
- {
- BufferedReader br;
- StringTokenizer st;
- final private int BUFFER_SIZE = 1 << 16;
- private DataInputStream din;
- private byte[] buffer;
- private int bufferPointer, bytesRead;
- public Reader()
- {
- din = new DataInputStream(System.in);
- buffer = new byte[BUFFER_SIZE];
- bufferPointer = bytesRead = 0;
- }
- String next(){
- while(st==null || !st.hasMoreElements()){
- try{
- st=new StringTokenizer(br.readLine());
- }catch(Exception e){
- }
- }
- return st.nextToken();
- }
- public Reader(String file_name) throws IOException
- {
- din = new DataInputStream(new FileInputStream(file_name));
- buffer = new byte[BUFFER_SIZE];
- bufferPointer = bytesRead = 0;
- }
- public String readLine() throws IOException
- {
- byte[] buf = new byte[64]; // line length
- int cnt = 0, c;
- while ((c = read()) != -1)
- {
- if (c == '\n')
- break;
- buf[cnt++] = (byte) c;
- }
- return new String(buf, 0, cnt);
- }
- public int nextInt() throws IOException
- {
- int ret = 0;
- byte c = read();
- while (c <= ' ')
- c = read();
- boolean neg = (c == '-');
- if (neg)
- c = read();
- do
- {
- ret = ret * 10 + c - '0';
- } while ((c = read()) >= '0' && c <= '9');
- if (neg)
- return -ret;
- return ret;
- }
- public long nextLong() throws IOException
- {
- long ret = 0;
- byte c = read();
- while (c <= ' ')
- c = read();
- boolean neg = (c == '-');
- if (neg)
- c = read();
- do {
- ret = ret * 10 + c - '0';
- }
- while ((c = read()) >= '0' && c <= '9');
- if (neg)
- return -ret;
- return ret;
- }
- public double nextDouble() throws IOException
- {
- double ret = 0, div = 1;
- byte c = read();
- while (c <= ' ')
- c = read();
- boolean neg = (c == '-');
- if (neg)
- c = read();
- do {
- ret = ret * 10 + c - '0';
- }
- while ((c = read()) >= '0' && c <= '9');
- if (c == '.')
- {
- while ((c = read()) >= '0' && c <= '9')
- {
- ret += (c - '0') / (div *= 10);
- }
- }
- if (neg)
- return -ret;
- return ret;
- }
- private void fillBuffer() throws IOException
- {
- bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
- if (bytesRead == -1)
- buffer[0] = -1;
- }
- private byte read() throws IOException
- {
- if (bufferPointer == bytesRead)
- fillBuffer();
- return buffer[bufferPointer++];
- }
- public void close() throws IOException
- {
- if (din == null)
- return;
- din.close();
- }
- }
- //Super Fast I/O Class End
- static int maxN=10000007;
- static long[] dp=new long[maxN];
- static TreeMap<Integer, Integer> map=new TreeMap<>();
- public static void main(String[] args) throws IOException {
- Main mn=new Main();
- // I/O System start
- Reader inf=new Reader();
- FastReader in=new FastReader();
- Scanner inp=new Scanner(System.in);
- PrintWriter out=new PrintWriter(System.out);
- // I/O System End
- long a=in.nextLong();
- long b=in.nextLong();
- System.out.println(mn.pow(a, b));
- }
- static int k=0;
- public long getFibo(long n,long a,long b){
- //System.out.println("Count : "+k++);
- //if(n<0) return 0;
- //if(n==1) return 1;
- if(n<=0) return 0;
- //if(map.get((int)n)!= null) return map.get((int)n);
- if(dp[(int)n]!=-1)return dp[(int)n];
- //long value=getFibo(n-1)+getFibo(n-2);
- dp[(int)n]=Math.max(getFibo(n-1,a,b),getFibo(n-1,b,a));
- //map.put((int)n, (int)value);
- //dp[(int)n]=(int)value;
- //return value;
- return dp[(int)n];
- }
- //get power in O(sqrt-n) complexity
- public long pow(long a,long b){
- if(b==0)return 1;
- if(b%2==0)return pow(a*a,b/2);
- else{
- return a*pow(a,b-1);
- }
- }
- //get gcd
- public long gcd(long a,long b)
- {
- if(a==0){
- return b;
- }else{
- return gcd(b%a,a);
- }
- }
- //get lcm
- public long lcm(long a,long b){
- return a*(b/gcd(a,b));
- }
- //get sub sequence
- public static ArrayList<String> getAllSubSequence(String str)
- {
- if (str.length() == 0) {
- ArrayList<String> empty = new ArrayList<>();
- empty.add("");
- return empty;
- }
- char ch = str.charAt(0);
- String subStr = str.substring(1);
- ArrayList<String> subSequences =getAllSubSequence(subStr);
- ArrayList<String> res = new ArrayList<>();
- for (String val : subSequences) {
- res.add(val);
- res.add(ch + val);
- }
- res.remove("");
- return res;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement