UVA Solution 135 - No Rectangles Solution in C | Volume 1 - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Saturday, April 29, 2017

UVA Solution 135 - No Rectangles Solution in C | Volume 1

UVA Solution 135 - No Rectangles Solution in C | Volume 1


Problem Name: No Rectangles
Problem Number : UVA - 135
Online Judge : UVA Online Judge Solution
Volume: 1
Solution Language : C


UVA Solution 135 Code in C:

#include <stdio.h> 

int main() {
 int K, cases = 0;
 while(scanf("%d", &K) == 1) {
  if(cases++) puts("");
  int m = K-1;
  for(int i = 0; i < K; i++) {
   printf("%d", 1);
   for(int j = 1; j < K; j++)
    printf(" %d", i * m + j + 1);
   puts("");
  }
  
  for(int i = 0; i < m; i++) {
   for(int j = 0; j < m; j++) {
    printf("%d", i+2);
    for(int s = 0; s < m; s++)
     printf(" %d", (j + s * i)%m + s*m + K + 1);
    puts("");
   }
  }
 }
 return 0;
}

No comments:

Post a Comment