publicstaticvoidsolve() { char[] s = io.next().toCharArray(); intn= s.length; longcnt= n, sum = 1L; for (inti=0; i < n; ) { intj= i + 1; while (j < n && s[j] == s[j - 1]) { j++; } sum = sum * (j - i) % MOD; cnt--; i = j; } for (longi=1; i <= cnt; i++) { sum = sum * i % MOD; } io.println(cnt + " " + sum); }
publicstaticvoidsolve() { intn= io.nextInt(), k = io.nextInt(); intans=0, i; for (i = 1; i + k - 1 <= n; i += k) { io.println("? " + i); io.flush(); ans ^= io.nextInt(); } for (; i <= n; i++) { io.println("? " + (i - k + 1)); io.flush(); ans ^= io.nextInt(); } io.println("! " + ans); io.flush(); }