{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"``` \r\nint work(char * s, int n, int base, int p){\r\n long long ans \u003d 0; \r\n for(int i \u003d 1; i \u003c\u003d n; i++)\r\n ans \u003d (ans\\times base + s[i]) % p; \r\n return ans;\r\n}\r\n```\r\n以上代码为一种字符串 $hash$ 的写法,给出 $base$ 和 $p$ ,试统计长度小于等于 $n$ 且能使最后 $hash$ 值为 $x$ 的字符串(只能包含小写字母)有多少个。"}},{"title":"Input","value":{"format":"MD","content":"四个数, $n$ , $base$ , $p$ , $x(1\\le n,p,base\\le 50000 , 0\\le x \u003c p)$"}},{"title":"Output","value":{"format":"MD","content":"一个数表示答案(对 $998244353$ 取模)"}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2 3 7 5\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e100\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}