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

UVa : 136 (Ugly Numbers)


Data type:
Long integer

Algorithm:


Two = Three = Five = 1 [First ugly number]

long Minimum () {
    if ( (2 * Two) minimum than (3 * Three) and (5 * Five) ) then
        return (2 * Two) and update : Two = Next ugly number

    else if ( (3 * Three) minimum than (2 * Two) and (5 * Five) ) then
        return (3 * Three) and update : Three = Next ugly number

    else if ( (5 * Five) minimum than (3 * Three) and (2 * Two) ) then
        return (5 * Five) and update : Five = Next ugly number
}

consecutive two returned value would be same, so carefully choose distinct value.
Or,

we can manually find the 1500th ugly number, tho it’s a time consuming process.

List of ugly numbers, below 10000
1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192, 200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384, 400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675, 720, 729, 750, 768, 800, 810, 864, 900, 960, 972, 1000, 1024, 1080, 1125, 1152, 1200, 1215, 1250, 1280, 1296, 1350, 1440, 1458, 1500, 1536, 1600, 1620, 1728, 1800, 1875, 1920, 1944, 2000, 2025, 2048, 2160, 2187, 2250, 2304, 2400, 2430, 2500, 2560, 2592, 2700, 2880, 2916, 3000, 3072, 3125, 3200, 3240, 3375, 3456, 3600, 3645, 3750, 3840, 3888, 4000, 4050, 4096, 4320, 4374, 4500, 4608, 4800, 4860, 5000, 5120, 5184, 5400, 5625, 5760, 5832, 6000, 6075, 6144, 6250, 6400, 6480, 6561, 6750, 6912, 7200, 7290, 7500, 7680, 7776, 8000, 8100, 8192, 8640, 8748, 9000, 9216, 9375, 9600, 9720

The 1500′th ugly number is 8 5_ _6 3 3 _ 2. // fill the blanks with same digit.

UVa : 200 (Rare Order)


অনেকগুলো string (array of characters) দেয়া থাকবে ।
character গুলোকে column-wise print করতে হবে
মানে, প্রথম কলাম প্রিন্ট করতে হবে, তারপর দ্বিতীয় কলাম, তারপর তৃতীয় .. এইভাবে
একটি character শুধুমাত্র একবারই প্রিন্ট হবে।

Sample input টা দেখি,
১ম কলাম এ কোন কোন characters আছে ? XZZZY
২য় কলাম এ কোন কোন characters আছে ? WXXXW
৩য় কলাম এ কোন কোন characters আছে ? YYWW
৪র্থ কলাম এ কোন কোন characters আছে ? X

আমরা এখন ১ম কলাম থেকে characters print করা শুরু করব,

১ম কলাম এ ছিল, XZZZY
একটি character শুধুমাত্র একবারই প্রিন্ট হবে।
তার মানে, ১ম কলাম এ আসলে আছে, XZY
৩ টা Z বাদ দিয়ে একটা Z রাখলাম, এবং এটা প্রিন্ট করে দিলাম
print : XZY

২য় কলাম এ ছিল, WXXXW
২য় কলাম এ আসলে আছে, WX
আমরা কিন্তু X একবার প্রিন্ট করেছিলাম, তাই আবার X প্রিন্ট করতে পারব না
শুধু প্রিন্ট করব,
print : W

৩য় কলাম এ ছিল, YYWW
৩য় কলাম এ আসলে আছে, YW
Yএবং W দুটোই আগে প্রিন্ট করা হয়েছে।

৪র্থ কলাম এ আছে, এটি আগেই প্রিন্ট করেছি।

তাহলে, আমাদের সম্পূর্ণ আউটপুট হবে,
XZYW

এখন এইখানে কিছু কথা আছে :

১. একটা করে ইনপুট নিলাম আর সেটা প্রসেস করে আউটপুট দিলাম
এই বুদ্ধি কিন্তু কাজে লাগবে না । প্রথমেই সব ইনপুট একবারে নিতে হবে
তারপর সেটা সেইভ করে রাখতে হবে।

২. C দিয়া করলে 2 dimensional character array নিতে হবে।
কিন্তু এখানে row size বলা নাই, column size বলা আছে।
ধরে নেয়া যেতে পারে, row size = 5000

৩. সবগুলা স্ট্রিং কিন্তু সমান না ।
কাজেই garbage value ‘র ব্যাপারে সর্তক থাকতে হবে

Critical input:
HELLO
ELLOH
EREREEEIE
W
ADFEEDE
OEREI
EEEIADFIOS
PAVMZVNZV
#

Critical output:
HEWAOPLRDFVIMZNS

Critical input:
TYKK
DCDDE
BMZOLWO
PCZL
TKKYOSWQ
ILUVL
#

Critical output:
TDBPIYCMKLZUOVEWSQ

 

#include
#include

int main ()
{
	char A [5000] [21], Temp[21];
	int I = 0, Len, N, J;
	int L[26] = {0};

	while (scanf("%s", Temp)){ // input taken in Temp

		if (Temp [0] == '#') // break condition
			break;

		Len = strlen (Temp);

		for (J = 0; J < Len; J++) // Array intialized
			A [I] [J] = Temp [J];

		while (J != 21) // avoid garbage value
			A [I] [J++] = 'a';
		I++;
	}

	for (J = 0; J < 21; J++){

		for (N = 0; N < I; N++){ 			if (A [N] [J] > 64 && A [N] [J] < 91)
				L [ (A [N] [J] - 65) ]++;

			if (L [ ( A [N] [J] - 65) ] == 1)
				printf("%c", A [N] [J]);
		}
	}

	printf("\n");

	return 0;
}

Online Judges


UVa Online Judge

Check out Test Cases on UVa Toolkit ]

UVa Problem Set Official site ]

External Problem set Loads faster.
External problem set url format: http://uva.onlinejudge.org/external/1/100.html

String BASE_URL = "http://uva.onlinejudge.org/";
int VOLUME_NUMBER = 1;
int PROBLEM_NUMBER = 100;

print (BASE_URL + "external/" + VOLUME_NUMBER + "/" + PROBLEM_NUMBER + ".html");

UVa Problem Set Un-official site (use when UVa server is down) ]

Problems Hints:
Algorithmist ]
Steven Halim ]
Problem Tools (shygypsy) ]

Problem Rank list:
Hunting Problems ]
Problem Rank list ]
Another Rank list ]

My Ranking ]

——————-

USACO

Training ]
Contest ]
Forum ]

——————-

CodeChef

Official site ]

——————-

TJU Online Judge :

Official site ]

——————-

TopCoder

Official site ]

My Ranking ]

——————-

CodeForces

Official site ]

My Ranking ]

——————-

IARCS (Indian National Olympiad in Informatics)

Test Data is given with each problems. Some solutions can be found of particular problem.

Problems ]

——————-

Project Euler :

Series of challenging mathematical/computer programming problems.
After solving a problem, a discussion forum of respective problem will be opened.

Official site ]

Statistics : [ Bangladesh ]

——————-

Sphere Online Judge :

Official site ]

——————-

Code Jam :

Official site ]
Source code ]

——————-

Saratov Online Judge :

Official site ]

——————-

Croatian Open Competition in Informatics :

High School Programming Contest site.
Test data + Sample solutions + Editorials are available of previous contests.

Official site ]

Favorite Site/Blog :

One problem a day ]

Smilitude ]

Shafaet Planet ]

Young Programmer ]

Come on Code on ]

Ruet Programmer ]

Harsh ]

Puzzle ]

Quote ]

Php Tutorial ]

C/C++/Java/Bash/Asm Arena ]

Java Script Tutorial :
Echo ]
learn js ]

Cut the Knot ]

Combinatorial Game Theory ]

http://acmph.blogspot.com/ ]

http://opc.shaastra.org/ ]

http://dwite.ca/ ]

http://sp2hari.com/ ]

http://www.questtosolve.com/ ]

http://algoshare.blogspot.com/ ]

http://uvafcfm.wordpress.com/  ]

[ Math + Natural Science + Social Science + Humanities Tutorials Collection ]

Android:

Android for Beginners: [http://androidforbeginners.blogspot.com/ ]

Android Forum: [http://www.anddev.org/ ]

Some Web-site Links ] by Saidul Islam

Download Links of Some Essential Books

Introduction to Algorithms. ]
Programming Challenges. ]
Art of Programming Contest. ] [Elementary Level]