View Code of Problem 6

#include<stdio.h>
int main(){
	int a[101],b[101],step,T,n,j,kk,flag;
	scanf("%d",&T);
	scanf("%d",&n);
	flag=1;
	while(T--){
		for(int i=0;i<n;i++){
			scanf("%d%d",&a[i],&b[i]);
		}
		step=b[0];
		while(step<=a[j]){
			
			for(kk=step,j=1;j<n;j++){
				kk+=step;
				if(j!=n-1){
					if(kk<b[j] || kk>a[j+1] ){	
					flag=0;
					break;
					}				
					else continue;
				}
				else if(j==n-1){
					if(kk<b[j]){	
					flag=0;
					break;
					}				
					else continue;
				}
					if(flag==1){
			        printf("YES");
			        break;
			  }			
			   
			}
			step++;
		}
	
			else{
				printf("NO");
			}
		
	}
	return 0;	
}
/*
Main.c: In function 'main':
Main.c:39:4: error: 'else' without a previous 'if'
    else{
    ^
*/

Double click to view unformatted code.


Back to problem 6