結果
問題 |
No.219 巨大数の概算
|
ユーザー |
|
提出日時 | 2016-05-02 23:49:47 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 701 bytes |
コンパイル時間 | 2,087 ms |
コンパイル使用メモリ | 81,776 KB |
実行使用メモリ | 209,116 KB |
最終ジャッジ日時 | 2024-10-05 02:36:12 |
合計ジャッジ時間 | 9,017 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | TLE * 1 -- * 50 |
ソースコード
package yukicoder; import java.math.BigInteger; import java.util.Scanner; public class Main{ public static void main(String[] args)throws Exception{ new Main().solve(); } void solve(){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for(int i=0;i<n;i++){ long a=sc.nextLong(); long b=sc.nextLong(); String ans=pow(a,b).toString(); System.out.println(ans.charAt(0)+" "+ans.charAt(1)+" "+(ans.length()-1)); } } BigInteger pow(long a,long n){ BigInteger A=new BigInteger(String.valueOf(a)); BigInteger ans=BigInteger.ONE; while(n>=1){ if(n%2==0){ A=A.multiply(A); n/=2; }else if(n%2==1){ ans=ans.multiply(A); n--; } } return ans; } }