結果

問題 No.1258 コインゲーム
ユーザー 遭難者遭難者
提出日時 2020-10-19 09:36:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,484 ms / 2,000 ms
コード長 976 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 74,260 KB
実行使用メモリ 70,180 KB
最終ジャッジ日時 2023-09-28 13:12:23
合計ジャッジ時間 52,012 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 595 ms
64,596 KB
testcase_01 AC 661 ms
66,308 KB
testcase_02 AC 384 ms
61,068 KB
testcase_03 AC 1,107 ms
66,248 KB
testcase_04 AC 1,047 ms
66,196 KB
testcase_05 AC 463 ms
62,908 KB
testcase_06 AC 1,060 ms
66,148 KB
testcase_07 AC 328 ms
60,372 KB
testcase_08 AC 318 ms
60,700 KB
testcase_09 AC 790 ms
66,996 KB
testcase_10 AC 982 ms
66,356 KB
testcase_11 AC 1,024 ms
66,132 KB
testcase_12 AC 936 ms
66,588 KB
testcase_13 AC 551 ms
64,908 KB
testcase_14 AC 325 ms
61,036 KB
testcase_15 AC 1,281 ms
69,244 KB
testcase_16 AC 469 ms
61,692 KB
testcase_17 AC 1,018 ms
66,372 KB
testcase_18 AC 762 ms
66,304 KB
testcase_19 AC 706 ms
66,244 KB
testcase_20 AC 1,022 ms
66,096 KB
testcase_21 AC 1,032 ms
66,180 KB
testcase_22 AC 989 ms
66,480 KB
testcase_23 AC 801 ms
66,252 KB
testcase_24 AC 480 ms
62,868 KB
testcase_25 AC 857 ms
66,328 KB
testcase_26 AC 788 ms
66,312 KB
testcase_27 AC 1,004 ms
66,300 KB
testcase_28 AC 609 ms
63,640 KB
testcase_29 AC 570 ms
66,116 KB
testcase_30 AC 1,219 ms
66,488 KB
testcase_31 AC 671 ms
65,932 KB
testcase_32 AC 436 ms
61,332 KB
testcase_33 AC 1,046 ms
66,404 KB
testcase_34 AC 1,013 ms
66,460 KB
testcase_35 AC 647 ms
65,972 KB
testcase_36 AC 1,010 ms
66,556 KB
testcase_37 AC 720 ms
66,136 KB
testcase_38 AC 980 ms
66,548 KB
testcase_39 AC 558 ms
63,504 KB
testcase_40 AC 1,367 ms
68,456 KB
testcase_41 AC 1,332 ms
70,180 KB
testcase_42 AC 1,314 ms
68,260 KB
testcase_43 AC 1,193 ms
68,044 KB
testcase_44 AC 1,265 ms
68,440 KB
testcase_45 AC 1,320 ms
68,216 KB
testcase_46 AC 1,484 ms
69,208 KB
testcase_47 AC 1,266 ms
68,248 KB
testcase_48 AC 1,254 ms
68,344 KB
testcase_49 AC 1,303 ms
68,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int s = Integer.parseInt(sc.next());
		for(int q = 0 ; q < s ; q++){
			int n = Integer.parseInt(sc.next());
			int m = Integer.parseInt(sc.next());
			int x = Integer.parseInt(sc.next());
			long zz = 1;
			long zzz = 1 + m;
			long yyy = 1 - m;
			long yy = 1;
			while(n != 0){
				if(n % 2 != 0){
					zz *= zzz;
					yy *= yyy;
					zz %= (int)Math.pow(10 , 9) + 7;
					yy %= (int)Math.pow(10 , 9) + 7;
				}
				n /= 2;
				zzz *= zzz;
				yyy *= yyy;
				zzz %= (int)Math.pow(10 , 9) + 7;
				yyy %= (int)Math.pow(10 , 9) + 7;
			}
			if(x == 0) zz += yy;
			else zz -= yy;
			while(zz < 0) zz += (int)Math.pow(10 , 9) + 7;
			if(zz % 2 == 1) zz += (int)Math.pow(10 , 9) + 7;
			zz /= 2;
			zz %= (int)Math.pow(10 , 9) + 7;
			ou.println(zz);
		}
		ou.flush();
		sc.close();
	}
}
0