結果

問題 No.747 循環小数N桁目 Hard
ユーザー GrenacheGrenache
提出日時 2019-05-04 14:18:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 4,573 bytes
コンパイル時間 3,358 ms
コンパイル使用メモリ 78,308 KB
実行使用メモリ 52,464 KB
最終ジャッジ日時 2024-06-22 11:45:02
合計ジャッジ時間 17,082 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
50,284 KB
testcase_01 AC 52 ms
50,344 KB
testcase_02 AC 52 ms
50,188 KB
testcase_03 AC 50 ms
50,392 KB
testcase_04 AC 47 ms
50,396 KB
testcase_05 AC 49 ms
50,300 KB
testcase_06 AC 51 ms
50,292 KB
testcase_07 AC 51 ms
50,292 KB
testcase_08 AC 51 ms
50,288 KB
testcase_09 AC 48 ms
49,844 KB
testcase_10 AC 48 ms
50,328 KB
testcase_11 AC 48 ms
50,276 KB
testcase_12 AC 49 ms
50,072 KB
testcase_13 AC 48 ms
50,344 KB
testcase_14 AC 48 ms
50,296 KB
testcase_15 AC 48 ms
50,412 KB
testcase_16 AC 47 ms
50,332 KB
testcase_17 AC 47 ms
50,488 KB
testcase_18 AC 53 ms
50,352 KB
testcase_19 AC 47 ms
50,388 KB
testcase_20 AC 48 ms
50,592 KB
testcase_21 AC 49 ms
50,268 KB
testcase_22 AC 48 ms
50,452 KB
testcase_23 AC 50 ms
50,268 KB
testcase_24 AC 51 ms
50,284 KB
testcase_25 AC 49 ms
49,992 KB
testcase_26 AC 50 ms
49,984 KB
testcase_27 AC 49 ms
50,304 KB
testcase_28 AC 48 ms
50,424 KB
testcase_29 AC 48 ms
50,336 KB
testcase_30 AC 48 ms
50,364 KB
testcase_31 AC 49 ms
50,152 KB
testcase_32 AC 48 ms
50,008 KB
testcase_33 AC 92 ms
51,388 KB
testcase_34 AC 87 ms
51,060 KB
testcase_35 AC 85 ms
50,872 KB
testcase_36 AC 87 ms
51,520 KB
testcase_37 AC 77 ms
50,952 KB
testcase_38 AC 86 ms
51,208 KB
testcase_39 AC 82 ms
51,184 KB
testcase_40 AC 96 ms
51,824 KB
testcase_41 AC 100 ms
51,808 KB
testcase_42 AC 93 ms
51,584 KB
testcase_43 AC 87 ms
51,352 KB
testcase_44 AC 90 ms
51,832 KB
testcase_45 AC 83 ms
51,656 KB
testcase_46 AC 95 ms
51,692 KB
testcase_47 AC 89 ms
51,780 KB
testcase_48 AC 86 ms
51,068 KB
testcase_49 AC 88 ms
51,496 KB
testcase_50 AC 83 ms
51,004 KB
testcase_51 AC 87 ms
51,580 KB
testcase_52 AC 83 ms
51,180 KB
testcase_53 AC 107 ms
52,464 KB
testcase_54 AC 96 ms
51,688 KB
testcase_55 AC 102 ms
51,748 KB
testcase_56 AC 98 ms
51,832 KB
testcase_57 AC 85 ms
51,028 KB
testcase_58 AC 109 ms
51,944 KB
testcase_59 AC 96 ms
51,620 KB
testcase_60 AC 104 ms
51,944 KB
testcase_61 AC 103 ms
52,216 KB
testcase_62 AC 97 ms
51,636 KB
testcase_63 AC 86 ms
51,612 KB
testcase_64 AC 88 ms
51,248 KB
testcase_65 AC 76 ms
50,828 KB
testcase_66 AC 95 ms
51,548 KB
testcase_67 AC 91 ms
51,808 KB
testcase_68 AC 94 ms
51,460 KB
testcase_69 AC 94 ms
51,520 KB
testcase_70 AC 73 ms
51,264 KB
testcase_71 AC 83 ms
51,308 KB
testcase_72 AC 84 ms
51,368 KB
testcase_73 AC 96 ms
51,724 KB
testcase_74 AC 94 ms
51,604 KB
testcase_75 AC 93 ms
51,508 KB
testcase_76 AC 90 ms
50,784 KB
testcase_77 AC 93 ms
51,316 KB
testcase_78 AC 94 ms
51,964 KB
testcase_79 AC 94 ms
51,436 KB
testcase_80 AC 97 ms
51,620 KB
testcase_81 AC 85 ms
51,024 KB
testcase_82 AC 88 ms
51,228 KB
testcase_83 AC 88 ms
51,168 KB
testcase_84 AC 97 ms
51,668 KB
testcase_85 AC 97 ms
51,840 KB
testcase_86 AC 87 ms
51,552 KB
testcase_87 AC 99 ms
51,668 KB
testcase_88 AC 89 ms
51,192 KB
testcase_89 AC 86 ms
51,220 KB
testcase_90 AC 94 ms
51,548 KB
testcase_91 AC 96 ms
51,516 KB
testcase_92 AC 83 ms
51,436 KB
testcase_93 AC 97 ms
51,764 KB
testcase_94 AC 100 ms
51,800 KB
testcase_95 AC 99 ms
51,744 KB
testcase_96 AC 101 ms
51,496 KB
testcase_97 AC 101 ms
52,224 KB
testcase_98 AC 108 ms
52,388 KB
testcase_99 AC 107 ms
52,340 KB
testcase_100 AC 102 ms
51,716 KB
testcase_101 AC 93 ms
51,608 KB
testcase_102 AC 92 ms
51,652 KB
testcase_103 AC 100 ms
51,564 KB
testcase_104 AC 99 ms
51,780 KB
testcase_105 AC 97 ms
51,752 KB
testcase_106 AC 102 ms
51,936 KB
testcase_107 AC 102 ms
51,944 KB
testcase_108 AC 101 ms
51,656 KB
testcase_109 AC 99 ms
52,004 KB
testcase_110 AC 102 ms
51,776 KB
testcase_111 AC 98 ms
51,672 KB
testcase_112 AC 104 ms
51,848 KB
testcase_113 AC 101 ms
51,516 KB
testcase_114 AC 98 ms
51,704 KB
testcase_115 AC 97 ms
51,864 KB
testcase_116 AC 96 ms
51,692 KB
testcase_117 AC 97 ms
51,920 KB
testcase_118 AC 101 ms
51,848 KB
testcase_119 AC 102 ms
51,832 KB
testcase_120 AC 102 ms
51,964 KB
testcase_121 AC 99 ms
51,676 KB
testcase_122 AC 99 ms
51,644 KB
testcase_123 AC 99 ms
51,728 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