結果

問題 No.747 循環小数N桁目 Hard
ユーザー GrenacheGrenache
提出日時 2019-05-04 14:18:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 4,573 bytes
コンパイル時間 4,468 ms
コンパイル使用メモリ 75,064 KB
実行使用メモリ 52,864 KB
最終ジャッジ日時 2023-09-04 13:13:44
合計ジャッジ時間 19,584 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
49,528 KB
testcase_01 AC 47 ms
49,484 KB
testcase_02 AC 46 ms
49,600 KB
testcase_03 AC 46 ms
47,604 KB
testcase_04 AC 46 ms
49,332 KB
testcase_05 AC 46 ms
49,276 KB
testcase_06 AC 47 ms
49,456 KB
testcase_07 AC 45 ms
49,140 KB
testcase_08 AC 46 ms
49,132 KB
testcase_09 AC 46 ms
49,160 KB
testcase_10 AC 46 ms
49,532 KB
testcase_11 AC 47 ms
49,408 KB
testcase_12 AC 47 ms
49,384 KB
testcase_13 AC 46 ms
49,152 KB
testcase_14 AC 47 ms
49,404 KB
testcase_15 AC 47 ms
49,588 KB
testcase_16 AC 46 ms
49,280 KB
testcase_17 AC 46 ms
49,136 KB
testcase_18 AC 46 ms
49,360 KB
testcase_19 AC 46 ms
49,300 KB
testcase_20 AC 46 ms
49,488 KB
testcase_21 AC 46 ms
49,496 KB
testcase_22 AC 45 ms
49,492 KB
testcase_23 AC 45 ms
49,336 KB
testcase_24 AC 46 ms
49,704 KB
testcase_25 AC 47 ms
49,100 KB
testcase_26 AC 46 ms
49,432 KB
testcase_27 AC 46 ms
49,328 KB
testcase_28 AC 46 ms
49,544 KB
testcase_29 AC 46 ms
49,276 KB
testcase_30 AC 46 ms
49,452 KB
testcase_31 AC 46 ms
47,324 KB
testcase_32 AC 47 ms
49,332 KB
testcase_33 AC 97 ms
50,928 KB
testcase_34 AC 85 ms
51,272 KB
testcase_35 AC 86 ms
50,904 KB
testcase_36 AC 91 ms
51,264 KB
testcase_37 AC 78 ms
50,992 KB
testcase_38 AC 90 ms
51,072 KB
testcase_39 AC 75 ms
51,628 KB
testcase_40 AC 98 ms
51,256 KB
testcase_41 AC 102 ms
51,596 KB
testcase_42 AC 98 ms
51,164 KB
testcase_43 AC 88 ms
50,904 KB
testcase_44 AC 94 ms
51,084 KB
testcase_45 AC 88 ms
51,244 KB
testcase_46 AC 94 ms
51,488 KB
testcase_47 AC 98 ms
50,800 KB
testcase_48 AC 89 ms
51,336 KB
testcase_49 AC 93 ms
51,040 KB
testcase_50 AC 88 ms
52,028 KB
testcase_51 AC 92 ms
51,224 KB
testcase_52 AC 85 ms
51,484 KB
testcase_53 AC 101 ms
52,864 KB
testcase_54 AC 101 ms
51,456 KB
testcase_55 AC 102 ms
51,472 KB
testcase_56 AC 101 ms
51,268 KB
testcase_57 AC 88 ms
51,092 KB
testcase_58 AC 112 ms
51,972 KB
testcase_59 AC 93 ms
51,088 KB
testcase_60 AC 102 ms
51,560 KB
testcase_61 AC 103 ms
52,760 KB
testcase_62 AC 97 ms
51,236 KB
testcase_63 AC 98 ms
51,080 KB
testcase_64 AC 78 ms
51,096 KB
testcase_65 AC 65 ms
50,800 KB
testcase_66 AC 92 ms
49,256 KB
testcase_67 AC 81 ms
51,560 KB
testcase_68 AC 94 ms
51,260 KB
testcase_69 AC 98 ms
51,376 KB
testcase_70 AC 85 ms
51,336 KB
testcase_71 AC 84 ms
51,328 KB
testcase_72 AC 81 ms
51,064 KB
testcase_73 AC 97 ms
51,588 KB
testcase_74 AC 87 ms
51,256 KB
testcase_75 AC 88 ms
51,260 KB
testcase_76 AC 89 ms
51,224 KB
testcase_77 AC 87 ms
50,888 KB
testcase_78 AC 99 ms
50,928 KB
testcase_79 AC 85 ms
51,120 KB
testcase_80 AC 95 ms
51,860 KB
testcase_81 AC 84 ms
51,120 KB
testcase_82 AC 76 ms
51,032 KB
testcase_83 AC 88 ms
50,852 KB
testcase_84 AC 100 ms
49,644 KB
testcase_85 AC 97 ms
51,316 KB
testcase_86 AC 90 ms
51,136 KB
testcase_87 AC 102 ms
51,372 KB
testcase_88 AC 87 ms
51,036 KB
testcase_89 AC 79 ms
51,184 KB
testcase_90 AC 96 ms
51,620 KB
testcase_91 AC 93 ms
51,520 KB
testcase_92 AC 85 ms
51,876 KB
testcase_93 AC 99 ms
51,772 KB
testcase_94 AC 99 ms
51,368 KB
testcase_95 AC 101 ms
51,204 KB
testcase_96 AC 102 ms
51,312 KB
testcase_97 AC 109 ms
52,464 KB
testcase_98 AC 104 ms
52,632 KB
testcase_99 AC 101 ms
52,576 KB
testcase_100 AC 106 ms
51,628 KB
testcase_101 AC 95 ms
51,452 KB
testcase_102 AC 98 ms
51,528 KB
testcase_103 AC 104 ms
51,452 KB
testcase_104 AC 101 ms
51,228 KB
testcase_105 AC 103 ms
51,152 KB
testcase_106 AC 105 ms
51,460 KB
testcase_107 AC 106 ms
51,536 KB
testcase_108 AC 100 ms
51,392 KB
testcase_109 AC 102 ms
52,064 KB
testcase_110 AC 102 ms
51,396 KB
testcase_111 AC 102 ms
51,220 KB
testcase_112 AC 102 ms
51,264 KB
testcase_113 AC 103 ms
50,100 KB
testcase_114 AC 104 ms
51,344 KB
testcase_115 AC 100 ms
51,112 KB
testcase_116 AC 101 ms
51,296 KB
testcase_117 AC 102 ms
51,192 KB
testcase_118 AC 103 ms
51,620 KB
testcase_119 AC 100 ms
51,972 KB
testcase_120 AC 103 ms
52,188 KB
testcase_121 AC 100 ms
51,572 KB
testcase_122 AC 103 ms
51,684 KB
testcase_123 AC 102 ms
51,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.NoSuchElementException;


public class Main_yukicoder747 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] n = sc.next().toCharArray();
		char[] k = sc.next().toCharArray();

		int mod2 = (n[n.length - 1] - '0') % 2;
		int mod3 = 0;
		for (char c : n) {
			mod3 += c - '0';
		}
		mod3 %= 3;
		if (mod3 == 2 && (k[k.length - 1] - '0') % 2 == 0) {
			mod3 = 1;
		}

		String ans = "285714";
		if (mod2 == 0 && mod3 == 0) {
			pr.println(ans.charAt(6 - 1));
		} else if (mod2 == 1 && mod3 == 1) {
			pr.println(ans.charAt(1 - 1));
		} else if (mod2 == 0 && mod3 == 2) {
			pr.println(ans.charAt(2 - 1));
		} else if (mod2 == 1 && mod3 == 0) {
			pr.println(ans.charAt(3 - 1));
		} else if (mod2 == 0 && mod3 == 1) {
			pr.println(ans.charAt(4 - 1));
		} else if (mod2 == 1 && mod3 == 2) {
			pr.println(ans.charAt(5 - 1));
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Scanner {
		BufferedReader br;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		private boolean isPrintable(int ch) {
			return ch >= '!' && ch <= '~';
		}

		private boolean isCRLF(int ch) {
			return ch == '\n' || ch == '\r' || ch == -1;
		}

		private int nextPrintable() {
			try {
				int ch;
				while (!isPrintable(ch = br.read())) {
					if (ch == -1) {
						throw new NoSuchElementException();
					}
				}

				return ch;
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		String next() {
			try {
				int ch = nextPrintable();
				StringBuilder sb = new StringBuilder();
				do {
					sb.appendCodePoint(ch);
				} while (isPrintable(ch = br.read()));

				return sb.toString();
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		int nextInt() {
			try {
				// parseInt from Integer.parseInt()
				boolean negative = false;
				int res = 0;
				int limit = -Integer.MAX_VALUE;
				int radix = 10;

				int fc = nextPrintable();
				if (fc < '0') {
					if (fc == '-') {
						negative = true;
						limit = Integer.MIN_VALUE;
					} else if (fc != '+') {
						throw new NumberFormatException();
					}
					fc = br.read();
				}
				int multmin = limit / radix;

				int ch = fc;
				do {
					int digit = ch - '0';
					if (digit < 0 || digit >= radix) {
						throw new NumberFormatException();
					}
					if (res < multmin) {
						throw new NumberFormatException();
					}
					res *= radix;
					if (res < limit + digit) {
						throw new NumberFormatException();
					}
					res -= digit;

				} while (isPrintable(ch = br.read()));

				return negative ? res : -res;
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		long nextLong() {
			try {
				// parseLong from Long.parseLong()
				boolean negative = false;
				long res = 0;
				long limit = -Long.MAX_VALUE;
				int radix = 10;

				int fc = nextPrintable();
				if (fc < '0') {
					if (fc == '-') {
						negative = true;
						limit = Long.MIN_VALUE;
					} else if (fc != '+') {
						throw new NumberFormatException();
					}
					fc = br.read();
				}
				long multmin = limit / radix;

				int ch = fc;
				do {
					int digit = ch - '0';
					if (digit < 0 || digit >= radix) {
						throw new NumberFormatException();
					}
					if (res < multmin) {
						throw new NumberFormatException();
					}
					res *= radix;
					if (res < limit + digit) {
						throw new NumberFormatException();
					}
					res -= digit;

				} while (isPrintable(ch = br.read()));

				return negative ? res : -res;
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		float nextFloat() {
			return Float.parseFloat(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			try {
				int ch;
				while (isCRLF(ch = br.read())) {
					if (ch == -1) {
						throw new NoSuchElementException();
					}
				}
				StringBuilder sb = new StringBuilder();
				do {
					sb.appendCodePoint(ch);
				} while (!isCRLF(ch = br.read()));

				return sb.toString();
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new NoSuchElementException();
			}
		}
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0