結果

問題 No.1275 綺麗な式
ユーザー 57tggx57tggx
提出日時 2020-10-18 18:14:52
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,754 bytes
コンパイル時間 2,305 ms
コンパイル使用メモリ 74,424 KB
実行使用メモリ 57,852 KB
最終ジャッジ日時 2023-09-28 13:20:18
合計ジャッジ時間 12,015 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,796 KB
testcase_01 AC 122 ms
55,752 KB
testcase_02 AC 122 ms
55,640 KB
testcase_03 AC 123 ms
55,856 KB
testcase_04 AC 122 ms
55,956 KB
testcase_05 AC 123 ms
56,172 KB
testcase_06 AC 122 ms
55,568 KB
testcase_07 AC 122 ms
56,084 KB
testcase_08 AC 123 ms
55,984 KB
testcase_09 AC 121 ms
55,804 KB
testcase_10 AC 122 ms
56,292 KB
testcase_11 AC 120 ms
56,120 KB
testcase_12 AC 121 ms
55,884 KB
testcase_13 AC 122 ms
55,524 KB
testcase_14 AC 121 ms
56,020 KB
testcase_15 AC 122 ms
55,920 KB
testcase_16 AC 122 ms
55,960 KB
testcase_17 AC 122 ms
55,624 KB
testcase_18 AC 123 ms
55,732 KB
testcase_19 AC 123 ms
56,232 KB
testcase_20 AC 123 ms
56,104 KB
testcase_21 AC 123 ms
55,956 KB
testcase_22 AC 125 ms
55,788 KB
testcase_23 AC 123 ms
55,696 KB
testcase_24 AC 123 ms
55,860 KB
testcase_25 AC 125 ms
55,548 KB
testcase_26 AC 123 ms
55,540 KB
testcase_27 AC 124 ms
55,800 KB
testcase_28 AC 123 ms
55,580 KB
testcase_29 AC 123 ms
56,084 KB
testcase_30 AC 121 ms
56,000 KB
testcase_31 AC 121 ms
55,876 KB
testcase_32 AC 121 ms
55,800 KB
testcase_33 AC 120 ms
55,808 KB
testcase_34 AC 122 ms
55,732 KB
testcase_35 AC 122 ms
55,716 KB
testcase_36 AC 121 ms
53,908 KB
testcase_37 AC 122 ms
55,888 KB
testcase_38 AC 121 ms
55,812 KB
testcase_39 AC 122 ms
56,116 KB
testcase_40 AC 121 ms
55,884 KB
testcase_41 AC 122 ms
55,860 KB
testcase_42 AC 122 ms
55,772 KB
testcase_43 AC 122 ms
55,492 KB
testcase_44 AC 122 ms
56,032 KB
testcase_45 WA -
testcase_46 AC 119 ms
55,800 KB
testcase_47 AC 121 ms
53,728 KB
testcase_48 AC 122 ms
55,952 KB
testcase_49 AC 122 ms
57,852 KB
testcase_50 AC 121 ms
55,992 KB
testcase_51 AC 120 ms
55,836 KB
testcase_52 AC 126 ms
55,972 KB
testcase_53 AC 124 ms
55,812 KB
testcase_54 AC 122 ms
55,836 KB
testcase_55 AC 122 ms
55,508 KB
testcase_56 AC 122 ms
55,628 KB
testcase_57 AC 122 ms
55,800 KB
testcase_58 AC 122 ms
55,808 KB
testcase_59 AC 123 ms
56,092 KB
testcase_60 AC 121 ms
55,776 KB
testcase_61 AC 122 ms
55,812 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 a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		long n = Long.parseLong(sc.next());
		if(n == 0) ou.println(2);
		else{
			long x = 1;
			long y = 0;
			long z = 0;
			long w = 1;
			long p = 2 * a;
			p %= (long)(Math.pow(10 , 9) + 7);
			long q = b - a * (long)a % 1000000007;
			q %= Math.pow(10 , 9) + 7;			
			if(q < 0) q += 1000000007;
			long r = 1;
			long s = 0;
			n--;
			while(n != 0){
				if((n & 1) == 1){
					long x_tmp, y_tmp, z_tmp, w_tmp;
					x_tmp = x * p % 1000000007 + y * r % 1000000007;
					x_tmp %= Math.pow(10 , 9) + 7;
					y_tmp = x * q % 1000000007 + y * s % 1000000007;
					y_tmp %= Math.pow(10 , 9) + 7;
					z_tmp = z * p % 1000000007 + w * r % 1000000007;
					z_tmp %= Math.pow(10 , 9) + 7;
					w_tmp = z * q % 1000000007 + w * s % 1000000007;
					w_tmp %= Math.pow(10 , 9) + 7;
					x = x_tmp;
					y = y_tmp;
					z = z_tmp;
					w = w_tmp;
				}
				long p_tmp, q_tmp, r_tmp, s_tmp;
				p_tmp = p * p % 1000000007 + q * r % 1000000007;
				p_tmp %= Math.pow(10 , 9) + 7;
				q_tmp = p * q % 1000000007 + q * s % 1000000007;
				q_tmp %= Math.pow(10 , 9) + 7;
				r_tmp = p * r % 1000000007 + r * s % 1000000007;
				r_tmp %= Math.pow(10 , 9) + 7;
				s_tmp = r * q % 1000000007 + s * s % 1000000007;
				s_tmp %= Math.pow(10 , 9) + 7;
				p = p_tmp;
				q = q_tmp;
				r = r_tmp;
				s = s_tmp;
				n >>= 1;
			}
			x = 2 * a * x % 1000000007 + 2 * y % 1000000007;
			x %= Math.pow(10 , 9) + 7;
			while(x < 0) x += Math.pow(10 , 9) + 7;
			ou.println(x);
		}
		ou.flush();
		sc.close();
	}
}
0