Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Count rotations divisible by 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// { Driver Code Starts
// Initial Template for C++

#include <bits/stdc++.h>
using namespace std;

// } Driver Code Ends


// User function Template for C++

class Solution{
public:
int countRotations(string N){
// code here
int count=0;
if(((N[0] -'0') + (N[N.length()-1] - '0')*10)%4==0){count++;}
for(int i=0;i<(N.length()-1);i++){
if(((N[i] - '0')*10 + (N[i+1] - '0'))%4==0)count++;
}
return count;
}
};

// { Driver Code Starts.

int main(){
int t;
cin>>t;
while(t--){
string N;
cin>>N;

Solution ob;
cout<<ob.countRotations(N)<<endl;
}
return 0;
} // } Driver Code Ends