結果

問題 No.1258 コインゲーム
ユーザー 遭難者
提出日時 2020-10-16 23:33:59
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 779 bytes
コンパイル時間 3,319 ms
コンパイル使用メモリ 77,456 KB
実行使用メモリ 52,324 KB
最終ジャッジ日時 2024-07-21 00:14:07
合計ジャッジ時間 10,014 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 49
権限があれば一括ダウンロードができます

ソースコード

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 z = 1 , y = 1;
			for(int i = 0 ; i < n ; i++){
				z *= 1 + m;
				y *= 1 - m;
				y %= (int)Math.pow(10 , 9) + 7;
				z %= (int)Math.pow(10 , 9) + 7;
			}
			if(x == 0) z += y;
			else z -= y;
			while(z < 0) z += (int)Math.pow(10 , 9) + 7;
			if(z % 2 == 1) z += (int)Math.pow(10 , 9) + 7;
			z /= 2;
			z %= (int)Math.pow(10 , 9) + 7;
			ou.println(z);
		}
		ou.flush();
		sc.close();
	}
}
0