#include<stdio.h>
#include<string.h>
int main(){
int k,i,l=0,t,v,L,x1,x2,x,R,g;
char e[10],s[10],d[7][10]={“sunday”,“monday”,“tuesday”,“wednesday”,“thursday”,“friday”,“saturday”};
scanf("%d",&g);
while(g–){
scanf("%s %s %d %d",s,e,&L,&R);
t=0,l=0;
while(1){
if(l>6)
l=0;
if(t==0){
k=strcmp(s,d[l]);
if(k==0){
x1=l;
t+=1; } }
if(t==1){
k=strcmp(e,d[l]);
if(k==0){
x2=l;
t+=1;}
}
if(t>1){
break;}
l+=1;
}
int p=x2,q=x1;
if(p>=q)
v=p-q+1;
else
v=8+p-q;
x=v;
i=0;
while(v<=R){
if(v>=L && v<=R)
i=i+1;
v=v+7;
}
if(i==0)
printf(“impossible\n”);
if(i==1)
printf("%d\n",x);
if(i>1)
printf(“many\n”);
}
return 0;
}
admin5
2
Could you please share the link of your solution
busi143
3
#include<stdio.h>
#include<string.h>
int main(){
int k,i,l=0,t,v,L,x1,x2,x,R,g;
char e[10],s[10],d[7][10]={“sunday”,“monday”,“tuesday”,“wednesday”,“thursday”,“friday”,“saturday”};
scanf("%d",&g);
while(g–){
scanf("%s %s %d %d",s,e,&L,&R);
t=0,l=0;
if(L<=R){
while(t<=1){
if(l>6)
l=0;
if(t==0){
k=strcmp(s,d[l]);
if(k==0){
x1=l;
t+=1; } }
if(t==1){
k=strcmp(e,d[l]);
if(k==0){
x2=l;
t+=1;}
}
l+=1;
}
int p=x2,q=x1;
if(p>=q)
v=p-q+1;
else
v=8+p-q;
x=v;
i=0;
while(v<=R){
if(v>=L && v<=R)
i=i+1;
v=v+7;
}
if(i==0)
printf("impossible\n");
if(i==1)
printf("%d\n",v-7);
if(i>1)
printf("many\n");
}}
return 0;
}