Contact Us Get link Facebook X Pinterest Email Other Apps Loading… Get link Facebook X Pinterest Email Other Apps Comments
Elavenil has a chessboard with N rows and M columns. In one step, he can choose two cells of the chessboard which share a common edge (that has not been cut yet) and cut this edge. Formally, the chessboard is split into two or more pieces if it is possible to partition its cells into two non-empty subsets S1 and S2 (S1∩S2=∅, |S1|+|S2|=NM) such that there is no pair of cells c1,c2 (c1∈S1,c2∈S2) which share a common edge that has not been cut.Elavenil does not want the board to split into two or more pieces. Compute the maximum number of steps he can perform while satisfying this condition. #include <stdio.h> int main() { int n,m; scanf("%d %d",&n,&m); printf("%d",(m-1)*(n-1)); return 0; } Read more
The Matriculation school have arranged an Annual Day Function.Volunteers have decorated a floor on various places of the school using Rose and Tulip flowers. But one of the coordinators requested the volunteers to rearrange the decoration like a triangular size.Coordinator also told them that tulips flowers need to be positioned at the middle of the roses #include <stdio.h> int main() {int rows; scanf("%d",&rows); for(int i=1;i<=rows;i++){ for(int j=1;j<=i;j++){ if(i==rows||i==j||j==1) printf("1 "); else printf("0 "); }printf("\n"); } return 0; } Read more
Mahesh has given a two-dimensional 3*3 array starting from A [0][0]. You should add the alternate elements of the array and print its sum. It should print two different numbers the first being sum of A 0 0, A 0 2, A 1 1, A 2 0, A 2 2 and A 0 1, A 1 0, A 1 2, A 2 1. #include <stdio.h> int main() { int A[3][3],i,j; for(i=0;i<3;i++) {for(j=0;j<3;j++) {scanf("%d ",&A[i][j]);}} int m=0,n=0; for(i=0;i<3;i++){ for(j=0;j<3;j++){ if((i+j)%2==0) m=m+A[i][j]; else n=n+A[i][j];}} printf("%d\n%d",m,n); return 0; } Read more
Comments
Post a Comment