結果

問題 No.1275 綺麗な式
ユーザー 遭難者遭難者
提出日時 2020-10-18 20:50:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 2,052 bytes
コンパイル時間 2,106 ms
コンパイル使用メモリ 74,960 KB
実行使用メモリ 57,620 KB
最終ジャッジ日時 2023-09-28 13:17:02
合計ジャッジ時間 13,656 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,780 KB
testcase_01 AC 122 ms
55,984 KB
testcase_02 AC 120 ms
55,576 KB
testcase_03 AC 121 ms
55,500 KB
testcase_04 AC 119 ms
56,148 KB
testcase_05 AC 120 ms
55,936 KB
testcase_06 AC 119 ms
55,856 KB
testcase_07 AC 119 ms
55,556 KB
testcase_08 AC 119 ms
55,736 KB
testcase_09 AC 118 ms
55,804 KB
testcase_10 AC 120 ms
55,552 KB
testcase_11 AC 122 ms
55,768 KB
testcase_12 AC 122 ms
56,056 KB
testcase_13 AC 121 ms
55,856 KB
testcase_14 AC 120 ms
55,860 KB
testcase_15 AC 120 ms
55,488 KB
testcase_16 AC 119 ms
55,756 KB
testcase_17 AC 118 ms
56,064 KB
testcase_18 AC 121 ms
55,960 KB
testcase_19 AC 119 ms
56,012 KB
testcase_20 AC 123 ms
55,808 KB
testcase_21 AC 121 ms
55,856 KB
testcase_22 AC 121 ms
56,152 KB
testcase_23 AC 122 ms
55,872 KB
testcase_24 AC 124 ms
53,732 KB
testcase_25 AC 121 ms
55,936 KB
testcase_26 AC 121 ms
56,188 KB
testcase_27 AC 121 ms
56,516 KB
testcase_28 AC 122 ms
55,964 KB
testcase_29 AC 119 ms
55,808 KB
testcase_30 AC 119 ms
56,100 KB
testcase_31 AC 120 ms
56,168 KB
testcase_32 AC 122 ms
55,712 KB
testcase_33 AC 122 ms
55,956 KB
testcase_34 AC 122 ms
55,720 KB
testcase_35 AC 118 ms
56,056 KB
testcase_36 AC 120 ms
56,156 KB
testcase_37 AC 121 ms
56,268 KB
testcase_38 AC 120 ms
53,808 KB
testcase_39 AC 120 ms
57,620 KB
testcase_40 AC 120 ms
55,908 KB
testcase_41 AC 119 ms
56,336 KB
testcase_42 AC 119 ms
55,892 KB
testcase_43 AC 119 ms
55,684 KB
testcase_44 AC 120 ms
56,280 KB
testcase_45 AC 120 ms
56,088 KB
testcase_46 AC 122 ms
53,960 KB
testcase_47 AC 122 ms
55,984 KB
testcase_48 AC 120 ms
55,716 KB
testcase_49 AC 121 ms
55,976 KB
testcase_50 AC 119 ms
55,612 KB
testcase_51 AC 122 ms
56,288 KB
testcase_52 AC 121 ms
55,704 KB
testcase_53 AC 121 ms
56,016 KB
testcase_54 AC 121 ms
55,744 KB
testcase_55 AC 120 ms
55,788 KB
testcase_56 AC 121 ms
55,908 KB
testcase_57 AC 121 ms
55,868 KB
testcase_58 AC 120 ms
55,776 KB
testcase_59 AC 119 ms
55,888 KB
testcase_60 AC 119 ms
55,552 KB
testcase_61 AC 120 ms
55,960 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);
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(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) % ((int)Math.pow(10 , 9) + 7);
			q %= Math.pow(10 , 9) + 7;
			while(q < 0) q += (int)Math.pow(10 , 9) + 7;
			long r = 1;
			long s = 0;
			n--;
			while(n != 0){
				if((n & 1) == 1){
					long xx = (x * p) % ((int)Math.pow(10 , 9) + 7) + (y * r) % ((int)Math.pow(10 , 9) + 7);
					xx %= Math.pow(10 , 9) + 7;
					long yy = (x * q) % ((int)Math.pow(10 , 9) + 7) + (y * s) % ((int)Math.pow(10 , 9) + 7);
					yy %= Math.pow(10 , 9) + 7;
					long zz = (z * p) % ((int)Math.pow(10 , 9) + 7) + (w * r) % ((int)Math.pow(10 , 9) + 7);
					zz %= Math.pow(10 , 9) + 7;
					long ww = (z * q) % ((int)Math.pow(10 , 9) + 7) + (w * s) % ((int)Math.pow(10 , 9) + 7);
					ww %= Math.pow(10 , 9) + 7;
					x = xx;
					y = yy;
					z = zz;
					w = ww;
				}
				long pp = (p * p) % ((int)Math.pow(10 , 9) + 7) + (q * r) % ((int)Math.pow(10 , 9) + 7);
				pp %= Math.pow(10 , 9) + 7;
				long qq = (p * q) % ((int)Math.pow(10 , 9) + 7) + (q * s) % ((int)Math.pow(10 , 9) + 7);
				qq %= Math.pow(10 , 9) + 7;
				long rr = (p * r) % ((int)Math.pow(10 , 9) + 7) + (r * s) % ((int)Math.pow(10 , 9) + 7);
				rr %= Math.pow(10 , 9) + 7;
				long ss = (r * q) % ((int)Math.pow(10 , 9) + 7) + (s * s) % ((int)Math.pow(10 , 9) + 7);
				ss %= Math.pow(10 , 9) + 7;
				p = pp;
				q = qq;
				r = rr;
				s = ss;
				n >>= 1;
			}
			x = (2 * (a * x) % ((int)Math.pow(10 , 9) + 7)) % ((int)Math.pow(10 , 9) + 7) + (2 * y) % ((int)Math.pow(10 , 9) + 7);
			x %= Math.pow(10 , 9) + 7;
			while(x < 0) x += Math.pow(10 , 9) + 7;
			ou.println(x);
		}
		ou.flush();
		sc.close();
	}
}
0