結果
問題 | No.933 おまわりさんこいつです |
ユーザー | tenten |
提出日時 | 2022-10-06 10:14:14 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 244 ms / 2,000 ms |
コード長 | 1,387 bytes |
コンパイル時間 | 1,916 ms |
コンパイル使用メモリ | 73,868 KB |
実行使用メモリ | 60,632 KB |
最終ジャッジ日時 | 2023-08-30 21:54:58 |
合計ジャッジ時間 | 5,162 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
49,336 KB |
testcase_01 | AC | 42 ms
49,328 KB |
testcase_02 | AC | 42 ms
49,220 KB |
testcase_03 | AC | 42 ms
49,340 KB |
testcase_04 | AC | 43 ms
49,320 KB |
testcase_05 | AC | 43 ms
49,324 KB |
testcase_06 | AC | 44 ms
49,216 KB |
testcase_07 | AC | 44 ms
49,272 KB |
testcase_08 | AC | 43 ms
49,268 KB |
testcase_09 | AC | 43 ms
49,420 KB |
testcase_10 | AC | 43 ms
49,252 KB |
testcase_11 | AC | 47 ms
49,116 KB |
testcase_12 | AC | 48 ms
49,220 KB |
testcase_13 | AC | 78 ms
51,576 KB |
testcase_14 | AC | 76 ms
51,852 KB |
testcase_15 | AC | 95 ms
52,276 KB |
testcase_16 | AC | 139 ms
54,964 KB |
testcase_17 | AC | 191 ms
55,540 KB |
testcase_18 | AC | 42 ms
49,336 KB |
testcase_19 | AC | 185 ms
55,300 KB |
testcase_20 | AC | 161 ms
55,820 KB |
testcase_21 | AC | 43 ms
49,268 KB |
testcase_22 | AC | 44 ms
49,204 KB |
testcase_23 | AC | 242 ms
59,960 KB |
testcase_24 | AC | 244 ms
60,632 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); long ans = 1; for (int i = 0; i < n; i++) { ans *= function(sc.nextLong()); ans = function(ans); } System.out.println(ans); } static long function(long x) { if (x < 10) { return x; } else { long sum = 0; while (x > 0) { sum += x % 10; x /= 10; } return function(sum); } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }