ACM (UVa) : 11479


Data type:
long long integer

Algorithm:
After taking the input, firstly sort the values, such X <= Y <= Z
if ( X + Y <= Z ) then print (Invalid) // Sum of two smaller sides is greater than larger sides.

Else if (X = Y and X = Z ) then print (Equilateral) // Equilateral, if all three sides r same in value

Else if (X = Y or X = Z or Y = Z ) then print (Isosceles) // Isosceles, if any two sides r same in value

Else if (X !=Y and Y != Z and X !=Z ) then print (Scalene) // Scalene, if all three sides r distinct

Critical input:
4
100 200 300
500 501 502
1000000000 1000000001 1000000002
963 852 741

Critical output:
Case 1: Invalid
Case 2: Scalene
Case 3: Scalene
Case 4: Scalene

ACM (UVa) : 11462


Data type:
long Integer

Algorithm:
hmm …
which sorting algorithm is going round in ur head ?? Quick sort !! or sth more efficient !!
while writing this post, till now I can efficiently use only bubble sort and rarely I did use insertion sort. Then, what abt our current problem !!

I have used Frequency sort !! sounds interesting, right ?
Suppose, we have an array of 10 elements, initially inserted 0

Index

0

1

2

3

4

5

6

7

8

9

Value

0

0

0

0

0

0

0

0

0

0

We have to sort these values: 5 6 3 2 0 1 4 7 5 0 6 3 2 1 5 6 8 4 5 2 3 2 1 4 6 2 1
Total 27 values
now, frequency wise increase values in array’s respective fields

Index

0

1

2

3

4

5

6

7

8

9

Value

2

4

5

3

3

4

4

1

1

0

Number of 0’s : 2
Number of 1’s : 4
Number of 2’s : 5

Number of 8’s : 1
Number of 9’s : 0
Just print the array index orderly, frequency wise.

Hmm …
UVa@Presentation_Error !!
bcoz, u print an extra space after last value.

Firstly, Flag = 0
loop () {
if ( Flag is equals to 1 ) then, print (space)
printf (Value)
Flag = 1
}

ACM (UVa) : 11520


Take input as a string
if u take input as character by character then it may cause input/output difficulties. Let,
char A [10] [11] // 2-D character array
scanf (“%s”, A [0]); // this will take input as string, save it in 0 indexed row (means, first row) and use sufficient column

Traverse each cell and check the possibilities of every character starting from A to Z. As soon as, a character will pass the possibilities then insert the character instead of empty cell, represented by a dot (.)

Let, Index starts from 1 to N, and A [10] [11] is a 2-D array
Suppose, we r checking a character C, whether it is appropriate, for a particular cell, A [Row] [Column]
if A [Row] [Column – 1] not equals to C and
A [Row – 1] [Column] not equals to C and
A [Row] [Column + 1] not equals to C and
A [Row + 1] [Column] not equals to C then
A [Row] [Column] must be assigned with C

Critical input:
2
5
..ABC
ABC..
ERWK.
…AB
EA…
4
..A.
A..A
.A..
A.A.

Critical output:
Case 1:
BCABC
ABCAB
ERWKA
ABCAB
EABCA
Case 2:
BCAB
ABCA
BABC
ABAB

#include <stdio.h>

long N;
char A[11][11];

int Check (long I, long J, long C)
{

	if (A[I][J-1]==C || A[I-1][J]==C || A[I][J+1]==C || A[I+1][J]==C)
			return 0;

	return 1;
}

int main ()
{
	//freopen ("11520out", "w", stdout);
	long T, I, J, C, Flag, Case=0;

	scanf ("%ld", &T);

	while (T){

		scanf("%ld", &N);

		for (I=0; I<N; I++)
			scanf("%s", A[I]);

		printf("Case %ld:\n", ++Case);

		for (I=0; I<N; I++){
			for (J=0; J<N; J++){
				Flag = 0;

				if (A[I][J]=='.'){
					for (C=65; Flag==0; C++){
						if (Check (I, J, C)){
							A[I][J] = C;
							Flag = 1;
						}
					}
				}
			}
		}

		for (I = 0; I<N; I++){
			for (J=0; J<N; J++)
				printf("%c", A[I][J]);
			printf("\n");
		}

		T--;
	}

	return 0;
}

ACM (UVa) : 11530


If we consecutively use scanf () and gets () then, it may create some input/output problem. For example,
Digit is an integer variable
A is a character array
scanf (“%ld”, & Digit);
gets (A);
printf (“%ld %s”, Digit, A);

Let, the input :
12
AABEDE

what will be the output ??
output will be just: 12

Basic Solution:
scanf (“%ld”, & Digit);
gets (A);
if (A [0] = end of string ) then gets (A);
printf (“%ld %s”, Digit, A);

Process:
Read the whole text as string, then judge each character in the following way:
if, a / d / g / j / m / p / w / <sp> then Count+=1
else if, b / e / h / k / n / q / u / x then Count+=2
else if, c / f / I / l / o / r / v / y then Count+=3
else if, s/ z then Count+=4
Output: Count

Critical input:
2
united international university
computer and telecommunication engineering

Critical output:
Case #1: 66
Case #2: 82

ACM (UVa) : 11547


Data type:
Long Integer

Algorithm:
Input: N
N *= 567
N /= 9
N +=7492
N *= 235
N /=47
N -=498
Output: tens column of N

Tens Column means,
if The final result is : 856253, then output: 5
if : 15324, output: 2
if : 163, output: 6
if : 74, output: 7
if : 9, output: 0

Critical input:
3
1000
-1000
953

Critical output:
6
3
5