結果

問題 No.747 循環小数N桁目 Hard
ユーザー tutuztutuz
提出日時 2018-10-19 23:52:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 521 ms / 2,000 ms
コード長 3,018 bytes
コンパイル時間 2,084 ms
コンパイル使用メモリ 75,004 KB
実行使用メモリ 56,712 KB
最終ジャッジ日時 2023-08-12 02:46:23
合計ジャッジ時間 30,863 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,752 KB
testcase_01 AC 43 ms
49,840 KB
testcase_02 AC 43 ms
49,696 KB
testcase_03 AC 44 ms
50,780 KB
testcase_04 AC 43 ms
49,636 KB
testcase_05 AC 43 ms
49,860 KB
testcase_06 AC 44 ms
49,872 KB
testcase_07 AC 43 ms
49,700 KB
testcase_08 AC 42 ms
49,584 KB
testcase_09 AC 43 ms
50,088 KB
testcase_10 AC 43 ms
50,004 KB
testcase_11 AC 44 ms
49,708 KB
testcase_12 AC 44 ms
49,720 KB
testcase_13 AC 42 ms
50,020 KB
testcase_14 AC 44 ms
50,180 KB
testcase_15 AC 44 ms
49,996 KB
testcase_16 AC 44 ms
50,324 KB
testcase_17 AC 42 ms
49,768 KB
testcase_18 AC 45 ms
49,964 KB
testcase_19 AC 45 ms
49,892 KB
testcase_20 AC 43 ms
49,692 KB
testcase_21 AC 43 ms
49,756 KB
testcase_22 AC 43 ms
49,892 KB
testcase_23 AC 44 ms
49,888 KB
testcase_24 AC 43 ms
49,672 KB
testcase_25 AC 44 ms
51,696 KB
testcase_26 AC 44 ms
49,900 KB
testcase_27 AC 43 ms
49,764 KB
testcase_28 AC 44 ms
49,692 KB
testcase_29 AC 43 ms
50,188 KB
testcase_30 AC 43 ms
49,832 KB
testcase_31 AC 44 ms
50,200 KB
testcase_32 AC 42 ms
49,764 KB
testcase_33 AC 256 ms
53,452 KB
testcase_34 AC 173 ms
53,264 KB
testcase_35 AC 127 ms
53,384 KB
testcase_36 AC 164 ms
53,120 KB
testcase_37 AC 126 ms
53,420 KB
testcase_38 AC 200 ms
53,484 KB
testcase_39 AC 192 ms
53,748 KB
testcase_40 AC 287 ms
53,940 KB
testcase_41 AC 310 ms
53,996 KB
testcase_42 AC 245 ms
53,752 KB
testcase_43 AC 120 ms
52,932 KB
testcase_44 AC 151 ms
52,864 KB
testcase_45 AC 279 ms
54,512 KB
testcase_46 AC 238 ms
53,348 KB
testcase_47 AC 245 ms
53,252 KB
testcase_48 AC 220 ms
54,504 KB
testcase_49 AC 221 ms
53,228 KB
testcase_50 AC 107 ms
52,876 KB
testcase_51 AC 106 ms
52,048 KB
testcase_52 AC 92 ms
53,268 KB
testcase_53 AC 409 ms
56,712 KB
testcase_54 AC 396 ms
54,364 KB
testcase_55 AC 446 ms
54,504 KB
testcase_56 AC 412 ms
54,360 KB
testcase_57 AC 166 ms
53,144 KB
testcase_58 AC 428 ms
56,312 KB
testcase_59 AC 151 ms
51,892 KB
testcase_60 AC 424 ms
53,668 KB
testcase_61 AC 269 ms
53,784 KB
testcase_62 AC 331 ms
53,640 KB
testcase_63 AC 264 ms
53,796 KB
testcase_64 AC 182 ms
53,276 KB
testcase_65 AC 87 ms
52,900 KB
testcase_66 AC 142 ms
51,936 KB
testcase_67 AC 186 ms
53,328 KB
testcase_68 AC 274 ms
54,096 KB
testcase_69 AC 235 ms
53,604 KB
testcase_70 AC 187 ms
53,592 KB
testcase_71 AC 112 ms
52,884 KB
testcase_72 AC 232 ms
54,352 KB
testcase_73 AC 271 ms
54,444 KB
testcase_74 AC 234 ms
54,100 KB
testcase_75 AC 117 ms
51,036 KB
testcase_76 AC 217 ms
53,672 KB
testcase_77 AC 116 ms
49,844 KB
testcase_78 AC 172 ms
52,992 KB
testcase_79 AC 221 ms
53,320 KB
testcase_80 AC 178 ms
53,124 KB
testcase_81 AC 152 ms
53,268 KB
testcase_82 AC 122 ms
53,028 KB
testcase_83 AC 158 ms
53,392 KB
testcase_84 AC 202 ms
52,664 KB
testcase_85 AC 183 ms
52,836 KB
testcase_86 AC 139 ms
52,988 KB
testcase_87 AC 301 ms
54,316 KB
testcase_88 AC 211 ms
53,584 KB
testcase_89 AC 220 ms
53,576 KB
testcase_90 AC 231 ms
53,312 KB
testcase_91 AC 285 ms
52,016 KB
testcase_92 AC 196 ms
53,580 KB
testcase_93 AC 265 ms
54,204 KB
testcase_94 AC 377 ms
53,712 KB
testcase_95 AC 431 ms
54,668 KB
testcase_96 AC 397 ms
54,240 KB
testcase_97 AC 452 ms
54,260 KB
testcase_98 AC 521 ms
56,092 KB
testcase_99 AC 338 ms
54,132 KB
testcase_100 AC 397 ms
54,928 KB
testcase_101 AC 189 ms
52,792 KB
testcase_102 AC 264 ms
53,380 KB
testcase_103 AC 228 ms
53,100 KB
testcase_104 AC 326 ms
53,744 KB
testcase_105 AC 328 ms
53,756 KB
testcase_106 AC 310 ms
53,944 KB
testcase_107 AC 207 ms
52,532 KB
testcase_108 AC 326 ms
53,716 KB
testcase_109 AC 207 ms
52,776 KB
testcase_110 AC 336 ms
53,916 KB
testcase_111 AC 319 ms
53,896 KB
testcase_112 AC 199 ms
52,876 KB
testcase_113 AC 339 ms
53,740 KB
testcase_114 AC 228 ms
52,612 KB
testcase_115 AC 207 ms
52,736 KB
testcase_116 AC 318 ms
53,636 KB
testcase_117 AC 219 ms
52,840 KB
testcase_118 AC 309 ms
53,580 KB
testcase_119 AC 320 ms
55,260 KB
testcase_120 AC 193 ms
52,624 KB
testcase_121 AC 327 ms
53,484 KB
testcase_122 AC 301 ms
53,708 KB
testcase_123 AC 333 ms
53,608 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