結果

問題 No.933 おまわりさんこいつです
ユーザー k_tsushimak_tsushima
提出日時 2020-01-01 08:32:03
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 2,316 bytes
コンパイル時間 2,792 ms
コンパイル使用メモリ 83,500 KB
実行使用メモリ 71,284 KB
最終ジャッジ日時 2024-05-01 11:18:49
合計ジャッジ時間 12,829 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
51,452 KB
testcase_01 AC 75 ms
51,016 KB
testcase_02 AC 76 ms
51,244 KB
testcase_03 AC 76 ms
51,444 KB
testcase_04 AC 77 ms
51,368 KB
testcase_05 AC 81 ms
51,028 KB
testcase_06 AC 78 ms
51,212 KB
testcase_07 AC 89 ms
51,224 KB
testcase_08 AC 89 ms
51,568 KB
testcase_09 AC 85 ms
51,640 KB
testcase_10 AC 94 ms
51,400 KB
testcase_11 AC 102 ms
52,056 KB
testcase_12 AC 127 ms
52,572 KB
testcase_13 AC 283 ms
56,384 KB
testcase_14 AC 331 ms
56,980 KB
testcase_15 AC 502 ms
57,172 KB
testcase_16 AC 1,503 ms
70,348 KB
testcase_17 AC 306 ms
57,080 KB
testcase_18 AC 75 ms
51,144 KB
testcase_19 AC 449 ms
57,140 KB
testcase_20 AC 1,009 ms
63,932 KB
testcase_21 AC 76 ms
51,268 KB
testcase_22 AC 75 ms
51,288 KB
testcase_23 TLE -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    BigInteger b = new BigInteger("1");
    for (int i = 0; i < n; i++) {
      b = b.multiply(new BigInteger(sc.next()));
    }
    List<Integer> ds = Stream.of(b.toString().split("")).mapToInt(Integer::parseInt).collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
    while (ds.size() > 1) {
      int sum = 0;
      for (int d : ds) sum += d;
      ds.clear();
      while (sum > 0) {
        ds.add(sum % 10);
        sum /= 10;
      }
    }
    System.out.println(ds.get(0));
  }
}
0