結果
問題 | No.2881 Mod 2^N |
ユーザー |
|
提出日時 | 2024-12-02 01:23:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 808 bytes |
コンパイル時間 | 231 ms |
コンパイル使用メモリ | 82,196 KB |
実行使用メモリ | 52,480 KB |
最終ジャッジ日時 | 2024-12-02 01:23:17 |
合計ジャッジ時間 | 3,513 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
# https://yukicoder.me/problems/no/2881 def main(): N, X, Y = map(int, input().split()) if X == Y: print(0) print("".join(map(str, []))) else: y = Y y_array = [] while y > 0: y_array.append(y % 2) y //= 2 y_array.reverse() if len(y_array) == 0 or y_array[-1] == 0: print(-1) return A = [N] index = 0 while index < len(y_array) - 1: i = 0 while index + i + 1 < len(y_array) and y_array[index + i + 1] == 0: i += 1 A.append(i + 1) index += i + 1 print(len(A)) print(" ".join(map(str, A))) if __name__ == "__main__": main()