You are not logged in. Please login at www.codechef.com to post your questions!

×

The Event program which I did,compiler showing wrong answer,can anyone please find the error?

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; }

asked 04 Dec '18, 09:55

busi143's gravatar image

0★busi143
1
accept rate: 0%

Could you please share the link of your solution

(04 Dec '18, 10:06) admin55★

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; }

link

answered 04 Dec '18, 10:29

busi143's gravatar image

0★busi143
1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×678

question asked: 04 Dec '18, 09:55

question was seen: 57 times

last updated: 04 Dec '18, 10:29