結果

問題 No.747 循環小数N桁目 Hard
ユーザー tutuztutuz
提出日時 2018-10-19 23:52:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 553 ms / 2,000 ms
コード長 3,018 bytes
コンパイル時間 2,383 ms
コンパイル使用メモリ 77,624 KB
実行使用メモリ 42,380 KB
最終ジャッジ日時 2024-04-29 17:24:08
合計ジャッジ時間 32,129 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
37,116 KB
testcase_01 AC 54 ms
36,984 KB
testcase_02 AC 54 ms
36,712 KB
testcase_03 AC 54 ms
37,276 KB
testcase_04 AC 53 ms
36,992 KB
testcase_05 AC 54 ms
37,208 KB
testcase_06 AC 53 ms
37,080 KB
testcase_07 AC 54 ms
36,848 KB
testcase_08 AC 53 ms
37,092 KB
testcase_09 AC 54 ms
37,120 KB
testcase_10 AC 54 ms
37,088 KB
testcase_11 AC 54 ms
37,232 KB
testcase_12 AC 53 ms
36,856 KB
testcase_13 AC 52 ms
37,156 KB
testcase_14 AC 54 ms
37,240 KB
testcase_15 AC 53 ms
36,848 KB
testcase_16 AC 55 ms
37,092 KB
testcase_17 AC 54 ms
37,208 KB
testcase_18 AC 52 ms
36,820 KB
testcase_19 AC 55 ms
37,240 KB
testcase_20 AC 54 ms
37,304 KB
testcase_21 AC 54 ms
37,064 KB
testcase_22 AC 53 ms
36,692 KB
testcase_23 AC 53 ms
36,860 KB
testcase_24 AC 53 ms
36,992 KB
testcase_25 AC 54 ms
37,172 KB
testcase_26 AC 53 ms
36,932 KB
testcase_27 AC 55 ms
37,200 KB
testcase_28 AC 56 ms
36,848 KB
testcase_29 AC 54 ms
37,236 KB
testcase_30 AC 53 ms
36,848 KB
testcase_31 AC 53 ms
36,820 KB
testcase_32 AC 55 ms
37,352 KB
testcase_33 AC 277 ms
40,272 KB
testcase_34 AC 196 ms
39,912 KB
testcase_35 AC 139 ms
39,712 KB
testcase_36 AC 193 ms
39,608 KB
testcase_37 AC 149 ms
39,680 KB
testcase_38 AC 218 ms
40,404 KB
testcase_39 AC 213 ms
40,176 KB
testcase_40 AC 307 ms
41,368 KB
testcase_41 AC 335 ms
40,868 KB
testcase_42 AC 277 ms
40,868 KB
testcase_43 AC 137 ms
39,256 KB
testcase_44 AC 170 ms
39,724 KB
testcase_45 AC 288 ms
40,744 KB
testcase_46 AC 267 ms
41,448 KB
testcase_47 AC 270 ms
40,400 KB
testcase_48 AC 229 ms
40,624 KB
testcase_49 AC 226 ms
40,516 KB
testcase_50 AC 119 ms
39,060 KB
testcase_51 AC 122 ms
39,200 KB
testcase_52 AC 105 ms
39,224 KB
testcase_53 AC 410 ms
41,776 KB
testcase_54 AC 417 ms
40,760 KB
testcase_55 AC 493 ms
42,016 KB
testcase_56 AC 452 ms
41,804 KB
testcase_57 AC 191 ms
39,900 KB
testcase_58 AC 438 ms
41,956 KB
testcase_59 AC 152 ms
39,380 KB
testcase_60 AC 467 ms
42,008 KB
testcase_61 AC 300 ms
40,576 KB
testcase_62 AC 353 ms
40,988 KB
testcase_63 AC 294 ms
40,732 KB
testcase_64 AC 201 ms
39,916 KB
testcase_65 AC 88 ms
38,656 KB
testcase_66 AC 166 ms
39,612 KB
testcase_67 AC 220 ms
39,996 KB
testcase_68 AC 289 ms
40,752 KB
testcase_69 AC 265 ms
40,524 KB
testcase_70 AC 194 ms
40,416 KB
testcase_71 AC 115 ms
39,264 KB
testcase_72 AC 256 ms
40,936 KB
testcase_73 AC 290 ms
40,728 KB
testcase_74 AC 259 ms
40,432 KB
testcase_75 AC 138 ms
39,196 KB
testcase_76 AC 241 ms
40,244 KB
testcase_77 AC 142 ms
39,148 KB
testcase_78 AC 193 ms
39,700 KB
testcase_79 AC 234 ms
40,032 KB
testcase_80 AC 205 ms
39,908 KB
testcase_81 AC 176 ms
39,548 KB
testcase_82 AC 128 ms
39,136 KB
testcase_83 AC 180 ms
39,816 KB
testcase_84 AC 217 ms
40,016 KB
testcase_85 AC 206 ms
39,772 KB
testcase_86 AC 149 ms
39,504 KB
testcase_87 AC 334 ms
40,784 KB
testcase_88 AC 222 ms
40,600 KB
testcase_89 AC 231 ms
40,092 KB
testcase_90 AC 260 ms
40,632 KB
testcase_91 AC 312 ms
41,144 KB
testcase_92 AC 210 ms
40,148 KB
testcase_93 AC 292 ms
41,048 KB
testcase_94 AC 413 ms
41,060 KB
testcase_95 AC 465 ms
42,132 KB
testcase_96 AC 425 ms
41,916 KB
testcase_97 AC 473 ms
41,980 KB
testcase_98 AC 553 ms
42,380 KB
testcase_99 AC 360 ms
41,588 KB
testcase_100 AC 432 ms
42,248 KB
testcase_101 AC 199 ms
39,736 KB
testcase_102 AC 281 ms
41,088 KB
testcase_103 AC 245 ms
40,232 KB
testcase_104 AC 352 ms
41,024 KB
testcase_105 AC 365 ms
40,992 KB
testcase_106 AC 335 ms
41,016 KB
testcase_107 AC 222 ms
40,020 KB
testcase_108 AC 354 ms
40,908 KB
testcase_109 AC 220 ms
39,996 KB
testcase_110 AC 384 ms
41,144 KB
testcase_111 AC 354 ms
40,800 KB
testcase_112 AC 221 ms
40,092 KB
testcase_113 AC 381 ms
41,036 KB
testcase_114 AC 244 ms
40,132 KB
testcase_115 AC 225 ms
40,128 KB
testcase_116 AC 357 ms
40,956 KB
testcase_117 AC 245 ms
40,152 KB
testcase_118 AC 349 ms
41,016 KB
testcase_119 AC 354 ms
40,924 KB
testcase_120 AC 221 ms
40,128 KB
testcase_121 AC 355 ms
40,916 KB
testcase_122 AC 335 ms
40,928 KB
testcase_123 AC 380 ms
41,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		int[] s = {2, 8, 5, 7, 1, 4};
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			BigInteger n = new BigInteger(in.nextString());
			BigInteger k = new BigInteger(in.nextString());

			int m = n.modPow(k, new BigInteger("6")).intValue() - 1;
			if (m < 0) m += 6;
			out.println(s[m]);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}
0