Cyclic Permutations
Practice
4.3 (17 votes)
Algorithms
Approved
Kmp algorithm
Medium
Z algorithm
Z Algorithm
Problem
88% Success 2069 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Given two binary strings A and B, count how many cyclic permutations of B when taken XOR with A give 0.

Input
First line contains T, the number of testcases. Each testcase consists of two lines, first line contains A and next line contains B.

Output
For each testcase, print required answer in one line.

Constraints
1 ≤ T ≤ 10
1 ≤ length(A) = length(B) ≤ 105

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
7 votes
Tags:
AlgorithmsKMP AlgorithmMediumOpenString ManipulationZ algorithmZ-algorithm
Points:30
5 votes
Tags:
AlgorithmsDynamic ProgrammingMediumReadyZ algorithmZ-algorithm
Points:30
13 votes
Tags:
ApprovedHash MapsMediumReadyString ManipulationZ algorithmZ-algorithm