Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- char s[10000005];
- int main()
- {
- double k;
- int i;
- long long c=0;
- while(~scanf("%lf %s", &k,s))
- {
- long long n=strlen (s);
- c+=n;
- if(c>10000000){
- printf("Invalid Input");
- return 1;
- }
- int chk27=0, chk5=0;
- if(k<1e7 && k>0 && k-(int)k==0 && strlen(s)<=1e7 && strlen(s)>0)
- {
- ;
- }
- else
- {
- puts("Invalid Input");
- return 1;
- }
- for (i=0; i<n; i++)
- {
- if(s[i]<'0'|| s[i]>'9')
- {
- break;
- }
- if (s[i]=='2'||s[i]=='7'){
- chk27++;
- }
- if (s[i]=='5'){
- chk5++;
- }
- }
- if(i!=strlen(s)|| chk5==0 || chk27==0)
- {
- puts("Invalid Input");
- return 1;
- }
- }
- puts("Valid Input");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement