結果
問題 | No.443 GCD of Permutation |
ユーザー |
![]() |
提出日時 | 2016-11-27 09:19:18 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 689 bytes |
コンパイル時間 | 2,781 ms |
コンパイル使用メモリ | 74,872 KB |
実行使用メモリ | 63,204 KB |
最終ジャッジ日時 | 2024-11-27 12:07:36 |
合計ジャッジ時間 | 31,097 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 25 WA * 3 |
ソースコード
package no443; import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { long stime = System.nanoTime(); Scanner sc = new Scanner(System.in); char[] s = sc.next().toCharArray(); int n = s.length; BigInteger gcd = new BigInteger(String.valueOf(s)); while((System.nanoTime() - stime) / 1000000 <= 800) { for(int i=0;i<n-1;i++) { int j = randInt(i,n-1); char temp = s[i]; s[i] = s[j]; s[j] = temp; } gcd = gcd.gcd(new BigInteger(String.valueOf(s))); } System.out.println(gcd); } public static int randInt(int min,int max) { return (int) (Math.random() * (max - min + 1)) + min; } }