結果
問題 |
No.1632 Sorting Integers (GCD of M)
|
ユーザー |
👑 |
提出日時 | 2021-07-30 22:07:17 |
言語 | C (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 912 bytes |
コンパイル時間 | 278 ms |
コンパイル使用メモリ | 30,592 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-16 00:22:13 |
合計ジャッジ時間 | 1,738 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 RE * 1 |
other | AC * 42 WA * 13 RE * 4 |
ソースコード
#include <stdio.h> const int Mod = 1000000007; long long div_mod(long long x, long long y, long long z) { if (x % y == 0) return x / y; else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y; } long long pow_mod(int n, int k) { long long N, ans = 1; for (N = n; k > 0; k >>= 1, N = N * N % Mod) if (k & 1) ans = ans * N % Mod; return ans; } int main() { int i, j, N, c[10]; scanf("%d", &N); for (i = 1; i <= 9; i++) scanf("%d", &(c[i])); for (i = 1; i <= 9; i++) if (c[i] == N) break; if (i <= 9) { printf("%lld\n", div_mod(pow_mod(10, N) - 1, 9, Mod) * i % Mod); fflush(stdout); return -1; } long long ans = 1, sum = 0; if (c[4] + c[8] == N) ans = 4; else if (c[2] + c[4] + c[6] + c[8] == N) ans = 2; for (i = 1; i <= 9; i++) sum += (long long)i * c[i]; if (sum % 9 == 0) ans *= 9; else if (sum % 3 == 0) ans *= 3; printf("%lld\n", ans); fflush(stdout); return 0; }