https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/the-dice-d4dc5b11/submissions/
#include <stdio.h>
int main(){
char str[1000000];
scanf("%s", str);
int c=0,i,flag=0;
for( i=0;str[i]!='\0';i++)
{
if(str[i] > '6')
{
flag=1;
break;
}
else if(str[i] == '6')
continue;
c++;
}
if(flag == 1 || str[i-1] == '6')
printf("-1");
else
printf("%d", c);
}
No comments:
Post a Comment