結果

問題 No.2649 [Cherry 6th Tune C] Anthem Flower
ユーザー tentententen
提出日時 2024-02-29 15:30:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 924 ms / 2,000 ms
コード長 1,949 bytes
コンパイル時間 2,547 ms
コンパイル使用メモリ 80,904 KB
実行使用メモリ 85,520 KB
最終ジャッジ日時 2024-02-29 15:30:21
合計ジャッジ時間 15,854 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
54,640 KB
testcase_01 AC 793 ms
85,116 KB
testcase_02 AC 797 ms
85,016 KB
testcase_03 AC 803 ms
85,520 KB
testcase_04 AC 807 ms
85,260 KB
testcase_05 AC 909 ms
85,328 KB
testcase_06 AC 924 ms
85,116 KB
testcase_07 AC 197 ms
63,356 KB
testcase_08 AC 196 ms
63,352 KB
testcase_09 AC 138 ms
56,900 KB
testcase_10 AC 139 ms
56,832 KB
testcase_11 AC 77 ms
55,132 KB
testcase_12 AC 105 ms
55,148 KB
testcase_13 AC 193 ms
59,556 KB
testcase_14 AC 189 ms
59,468 KB
testcase_15 AC 186 ms
58,672 KB
testcase_16 AC 198 ms
59,528 KB
testcase_17 AC 195 ms
59,248 KB
testcase_18 AC 218 ms
59,432 KB
testcase_19 AC 196 ms
59,484 KB
testcase_20 AC 195 ms
59,248 KB
testcase_21 AC 184 ms
59,480 KB
testcase_22 AC 192 ms
59,500 KB
testcase_23 AC 195 ms
59,216 KB
testcase_24 AC 182 ms
59,128 KB
testcase_25 AC 182 ms
59,208 KB
testcase_26 AC 181 ms
59,204 KB
testcase_27 AC 194 ms
59,256 KB
testcase_28 AC 185 ms
59,148 KB
testcase_29 AC 183 ms
59,192 KB
testcase_30 AC 184 ms
59,160 KB
testcase_31 AC 181 ms
59,228 KB
testcase_32 AC 185 ms
59,152 KB
testcase_33 AC 185 ms
57,280 KB
testcase_34 AC 720 ms
85,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int t = sc.nextInt();
        String result = IntStream.range(0, t).mapToObj(i -> {
            char[] input = sc.next().toCharArray();
            int m = sc.nextInt();
            int length = input.length;
            long base = 0;
            long half = 0;
            boolean isOdd = false;
            for (char c : input) {
                int x = c - '0';
                base *= 10;
                base += x;
                base %= m;
                half *= 10;
                half += isOdd ? 5 : 0;
                half += x / 2;
                half %= m;
                isOdd = (x % 2 == 1);
            }
            if (isOdd) {
                half++;
            } else {
                base++;
            }
            return String.valueOf(base * half % m);
        }).collect(Collectors.joining("\n"));
        System.out.println(result);
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0