結果
問題 |
No.1407 Kindness
|
ユーザー |
👑 |
提出日時 | 2021-02-26 21:59:20 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 919 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 30,080 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-02 14:39:42 |
合計ジャッジ時間 | 1,138 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
コンパイルメッセージ
main.c:4:11: warning: built-in function 'pow' declared as non-function [-Wbuiltin-declaration-mismatch] 4 | long long pow[100002]; | ^~~
ソースコード
#include <stdio.h> const int Mod = 1000000007; long long pow[100002]; 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 recursion(int l, char N[]) { if (l == 0 || N[0] == '0') return 0; else if (l == 1) return (N[0] - '0') * (N[0] - '0' + 1) / 2; else return (recursion(l - 1, &(N[1])) * (N[0] - '0') + pow[l-1] * (N[0] - '0') * (N[0] - '0' - 1) / 2) % Mod; } int main() { char N[100002]; scanf("%s", N); int i, l; for (i = 1, pow[0] = 1; i <= 100001; i++) pow[i] = pow[i-1] * 45 % Mod; for (l = 0; N[l] != 0; l++); if (l == 1) printf("%d\n", (N[0] - '0') * (N[0] - '0' + 1) / 2); else printf("%lld\n", (recursion(l - 1, &(N[1])) * (N[0] - '0') + pow[l-1] * (N[0] - '0') * (N[0] - '0' - 1) / 2 + div_mod((pow[l] - pow[1] + Mod) % Mod, 44, Mod)) % Mod); fflush(stdout); return 0; }