inlineintgetSub(int u, int d, int l, int r){ return g[d][r] - g[u-1][r] - g[d][l-1] + g[u-1][l-1]; }
intmain(){ read(n, m, a, b); for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ read(g[i][j]); g[i][j] += g[i][j-1] + g[i-1][j] - g[i-1][j-1]; } } int mx = 0; for(int x = 1; x <= a; x++){ for(int y = 1; y <= b; y++){ int u, d, l, r; if(x >= n) d = n; else d = x; if(x + n - 1 <= a) u = 1; else u = x - a + n; if(y >= m) r = m; else r = y; if(y + m - 1 <= b) l = 1; else l = y - b + m; res[x][y] = getSub(u, d, l, r); mx = max(mx, res[x][y]); } } for(int i = 1; i <= a; i++){ for(int j = 1; j <= b; j++) // printf("%d ", res[i][j]); printf("%d ", (int)(res[i][j] * 100.0 / mx)); puts(""); } return0; }
ULL h[N], base = 233, power[N]; // hash value of string s[1...i] is stored in h[i] voidHash(char s[]){ int len = strlen(s+1); h[1] = s[1]; for(int i = 2; i <= len; i++) h[i] = h[i-1] * base + s[i]; } ULL getSubstring(int l, int r){ // get hash value of s[l...r] return h[r] - h[l-1] * power[r-l+1]; }
boolcheck(int mid, int a, int b){ ULL h1 = -1, h2 = -1; if(mid <= a) h1 = h[mid]; else h1 = h[a] * power[mid-a] + h[mid-a]; if(mid <= b) h2 = h[mid]; else h2 = h[b] * power[mid-b] + h[mid-b]; return h1 == h2; }
boolcmp(int a, int b){ int l = 1, r = a + b; while(l < r){ int mid = (l + r) >> 1; if(check(mid, a, b)) l = mid + 1; else r = mid; } char A, B; if(l <= a) A = s[l]; else A = s[l-a]; if(l <= b) B = s[l]; else B = s[l-b]; return A > B; }
intmain(){ power[0] = 1, _10[0] = 1; for(int i = 1; i <= 200000; i++) power[i] = power[i-1] * base; for(int i = 1; i <= 100000; i++) _10[i] = _10[i-1] * 10ll % MOD; scanf("%s", s+1); n = strlen(s+1); Hash(s); for(int i = 1; i <= n; i++){ t[i] = i; p[i] = (p[i-1] * 10ll % MOD + (s[i] - '0')) % MOD; } sort(t+1, t+n+1, cmp); int ans = 0; for(int i = 1; i <= n; i++) ans = (1ll * ans * _10[t[i]] % MOD + p[t[i]]) % MOD; printf("%d\n", ans); return0; }