Md_Sakib_Hossain

Problem With BigInt

Oct 18th, 2021 (edited)
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.15 KB | None | 0 0
  1. package lightoj;
  2. import java.io.BufferedReader;
  3. import java.io.IOException;
  4. import java.io.InputStreamReader;
  5. import static java.lang.System.out;
  6. import java.math.BigInteger;
  7. import java.util.Scanner;
  8. import java.util.StringTokenizer;
  9.  
  10. public class LightOJ {
  11.  
  12.    
  13.     static BigInteger fn(int a,int b, int c, int d, int e, int f, int n)
  14.     {
  15.         BigInteger Big_a = BigInteger.valueOf(a);
  16.         BigInteger Big_b = BigInteger.valueOf(b);
  17.         BigInteger Big_c = BigInteger.valueOf(c);
  18.         BigInteger Big_d = BigInteger.valueOf(d);
  19.         BigInteger Big_e = BigInteger.valueOf(e);
  20.         BigInteger Big_f = BigInteger.valueOf(f);
  21.        
  22.         BigInteger Big_1 = BigInteger.valueOf(n-1);
  23.         BigInteger Big_2 = BigInteger.valueOf(n-2);
  24.         BigInteger Big_3 = BigInteger.valueOf(n-3);
  25.         BigInteger Big_4 = BigInteger.valueOf(n-4);
  26.         BigInteger Big_5 = BigInteger.valueOf(n-5);
  27.         BigInteger Big_6 = BigInteger.valueOf(n-6);
  28.        
  29.         BigInteger Big_Sum = BigInteger.valueOf(0);
  30.         BigInteger Big_Reminder =new BigInteger("10000007");
  31.        
  32.        
  33.        
  34.        
  35.        
  36.     if (n == 0) return Big_a;
  37.     if (n == 1) return Big_b;
  38.     if (n == 2) return Big_c;
  39.     if (n == 3) return Big_d;
  40.     if (n == 4) return Big_e;
  41.     if (n == 5) return Big_f;
  42.    
  43.    
  44.     for(int i=0;i<=n;i++)
  45.      Big_Sum = Big_Sum.add(Big_1).add(Big_2).add(Big_3).add(Big_4).add(Big_5).add(Big_6);
  46.        
  47.        
  48.     return Big_Sum;
  49.    
  50.    
  51.     }
  52.  
  53.     public static void main(String[] args) throws Exception{
  54.         FastReader scan = new FastReader();
  55.           int n,cases,a,b,c,d,e,f;;
  56.           cases = scan.nextInt();
  57.         for (int caseno = 1; caseno <= cases; ++caseno) {
  58.         a = scan.nextInt();
  59.         b = scan.nextInt();
  60.         c = scan.nextInt();
  61.         d = scan.nextInt();
  62.         e = scan.nextInt();
  63.         f = scan.nextInt();
  64.         n = scan.nextInt();
  65.         System.out.println("Case "+caseno+": "+fn(a,b,c,d,e,f,n));
  66.     }
  67.       //% 10000007
  68.       //  int N = 20;
  69.        
  70.     }
  71.    
  72.    
  73.     private static class FastReader {
  74.         BufferedReader br;
  75.         StringTokenizer st;
  76.  
  77.         public FastReader() {
  78.             br = new BufferedReader(new InputStreamReader(System.in));
  79.         }
  80.         String next()
  81.         {
  82.             while (st == null || !st.hasMoreElements()) {
  83.                 try {
  84.                     st = new StringTokenizer(br.readLine());
  85.                 }
  86.                 catch (IOException e) {
  87.                     e.printStackTrace();
  88.                 }
  89.             }
  90.             return st.nextToken();
  91.         }
  92.  
  93.         int nextInt() { return Integer.parseInt(next()); }
  94.  
  95.         long nextLong() { return Long.parseLong(next()); }
  96.  
  97.         double nextDouble(){ return Double.parseDouble(next()); }
  98.  
  99.         String nextLine()                                
  100.         {
  101.             String str = "";
  102.             try {
  103.                 str = br.readLine();
  104.             }
  105.             catch (IOException e) {
  106.                 e.printStackTrace();
  107.             }
  108.             return str;
  109.         }
  110.     }
  111.    
  112. }
  113.  
Add Comment
Please, Sign In to add comment