Skip to content

Commit

Permalink
Merge pull request #184 from gargarman0022/master
Browse files Browse the repository at this point in the history
Added a solution to problem 1593B
  • Loading branch information
jrijul1201 authored Oct 31, 2021
2 parents 2f3e24f + 525b63b commit dad89cd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
44 changes: 44 additions & 0 deletions CodeForces/1593B.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include<iostream>

using namespace std;

int main(){
int t;
cin>>t;
while(t--){
long long n;
cin>>n;
string s=to_string(n);
int len=s.length();
int m=len;
bool p=false;
bool q=false;
for(int i=(len-1);i>=0;i--){
if(s[i]=='5'){
for(int j=(i-1);j>=0;j--){
if((s[j]=='2') || (s[j]=='7')){
m=min(m,(len-2-j));
p=true;
}
else if(j==0){
break;
}
}
}
if(s[i]=='0'){
for(int j=(i-1);j>=0;j--){
if((s[j]=='5') || (s[j]=='0')){
m=min(m,(len-2-j));
q=true;
}
else if(j==0){
break;
}
}
}
if((p==true) && (q==true)){break;}
}
cout<<m<<endl;
}
return 0;
}
1 change: 1 addition & 0 deletions CodeForces/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Questions:-
Questions:-
1) [Codeforces : 1539B](1539B.cpp)
2) [Codeforces : 1509B](1509B.cpp)
3) [Codeforces : 1593B](1593B.cpp)

<hr>
<br>
Expand Down

0 comments on commit dad89cd

Please sign in to comment.