/* Find the rule first and find the rule formula. The formula is S * (2 ^ (M * k)-1)/(2 ^ s-1), and then the modulo needs to be continuously obtained, then, when the denominator is obtained, the reverse element is obtained based on the tip horse theorem. * // * Inverse element: ferma's theorem: If (A, P) is mutually qualitative and P is a prime number: Then a ^ (p-1) = 1 (% P) so the inverse element of A is X = a ^ (P-2) (% P) */# include <iostream> # include <cstring> # include <cstdio> # define Mo 1000000007 # define int _ int64 // This is a bit difficult to understand. This takes a long time, you cannot place int64 in every value of Mian. Using namespace STD; char a [100002];/* int fastmi (int A, int B) {int r = 1; int base = A; while (B! = 0) {If (B & 1) r = (R * base) % Mo; base = (base * base) % Mo; B >>= 1 ;} return R;} fast power: A number & 1 depends on the last digit after the number is converted into binary. Divide 11 by 2 and get 11 1101 r = 2, base = 2 ^ 2; 5 1001 r = 2 ^ 3, base = 2 ^ 4; 2 10 base = 2 ^ 8; 1 01 R = 2 ^ 11; 0 */INT fastmi (int A, int N) {If (n = 0) return 1; else if (N % 2 = 1) Return (A * fastmi (A, n-1) % Mo; else {int temp = fastmi (A, n/2 ); return (temp * temp) % Mo ;}} void main () {int I, S, K; while (CIN> A) {S = 0; int M = strlen (a); for (I = 0; I <m; I ++) if (A [I] = '0' | A [I] = '5') S = (S + fastmi (2, I) % Mo; scanf ("% i64d", & K); Int x = fastmi (2, m); int P = fastmi (x, k); P = (p-1 + Mo) % Mo; S = (S * P) % Mo; X = (X-1 + Mo) % Mo; X = fastmi (x, Mo-2) % Mo; // X is the inverse element of the denominator X to the MO, the Application of tip horse theorem. S = (S * X) % Mo; printf ("% i64d \ n", S);} return ;}