結果
問題 |
No.1632 Sorting Integers (GCD of M)
|
ユーザー |
|
提出日時 | 2024-09-08 15:43:40 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,242 bytes |
コンパイル時間 | 268 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 17,696 KB |
最終ジャッジ日時 | 2024-09-08 15:43:48 |
合計ジャッジ時間 | 7,219 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 42 WA * 13 TLE * 1 -- * 3 |
ソースコード
## https://yukicoder.me/problems/no/1632 MOD = 10 ** 9 + 7 def main(): N = int(input()) C = list(map(int, input().split())) # C > 0となるものが一つしかない場合は cnt = 0 cnt_i = -1 for i in range(9): if C[i] > 0: cnt += 1 cnt_i = i + 1 if cnt == 1: ans = 0 for _ in range(C[cnt_i - 1]): ans *= 10 ans %= MOD ans += cnt_i ans %= MOD print(ans) else: # 9で割れるか? mods = 1 nine_check = 0 for i in range(9): nine_check += (i + 1) * C[i] if nine_check % 9 == 0: mods *= 9 elif nine_check % 3 == 0: mods *= 3 four_check = True for i in range(9): if (i + 1) % 4 != 0 and C[i] > 0: four_check = False break two_check = True for i in range(9): if (i + 1) % 2 != 0 and C[i] > 0: two_check = False break if four_check: mods *= 4 elif two_check: mods *= 2 print(mods) if __name__ == "__main__": main()