結果
問題 |
No.747 循環小数N桁目 Hard
|
ユーザー |
![]() |
提出日時 | 2020-07-24 02:26:48 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,712 bytes |
コンパイル時間 | 110 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-10-12 06:42:11 |
合計ジャッジ時間 | 6,727 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 RE * 91 |
ソースコード
#n = int(input()) #入力 #a, b = (int(x) for x in input().split()) #a = [int(x) for x in input().split()] #a = list(map(int, input().split())) #a = [list(map(int,input().split(" "))) for i in range(N)] #2次元 #a.sort() # C++ の sort(a.begin(), a.end()); #a.append(3) # C++ の a.push_back(3); #exit(0) # return 0 的な。終了できる。 import math import copy #math.gcd(a, b) で、gcd 計算できる。 #math.pi は円周率。 INF = 10**18 #べき乗 C++ の pow(10, 18) or 1e18; pi = math.pi large_P = 1000000007 #large_P = 1000000009 #large_P = 998244353 #繰り返し2乗法 #N^aの、Mで割った余りを求める。 def my_pow(N, a, M): if(a == 0): return 1 else: if(a % 2 == 0): tempo = my_pow(N, a/2, M) return (tempo * tempo) % M else: tempo = my_pow(N, a - 1, M) return (tempo * N) % M #N_C_a を M で割った余り def my_combination(N, a, M): res = 1 for i in range(0, a): res *= N - i res %= M for i in range(0, a): res *= my_pow(i + 1, M - 2, M) res %= M return res #N_C_i を M で割った余りを、v[i] に代入する。 def my_combination_table(N, M, v): if(len(v) < N + 1): l = N + 1 - len(v) tempo = [1] * l v.extend(tempo) for i in range(1, N + 1): v[i] = v[i - 1] * (N - (i - 1)) v[i] %= M v[i] *= my_pow(i, M - 2, M) v[i] %= M return #math.factorial で階乗は計算できる。 #math.gcd で gcd は計算できる。 N = int(input()) K = int(input()) N %= 6 K = K % 2 + 2 res = my_pow(N, K, 6) arr = [4, 2, 8, 5, 7, 1] print(arr[res])