SPOJ: TDPRIMES – Printing some primes

Problem Link http://www.spoj.com/problems/TDPRIMES/ Problem Description In this problem,we need to print 1st,101st,201st…….primes less than 10^8. Concepts Used This problem is based on prime sieve(Sieve of Eratosthenes).. Code #include<stdio.h> #include<vector> /*To check whether a number i is prime or not,we need to check a[i/2] or a[i>>1] whether it is true or false*/ #define isprime(i) (a[i>>1]) /*number […]

Continue reading


SPOJ: CPRIME – Prime Number Theorem

Problem Link http://www.spoj.com/problems/CPRIME/ Problem Description In this problem,we need to find percentage error for prime number theorem ((pi(x)-lnx)/pi(x)) % where pi(x) =number of primes not greater than x. Concepts Used This problem is based on prime sieve(Sieve of Eratosthenes).. Code #include<stdio.h> #include<vector> #include<math.h> /*To check whether a number i is prime or not,we need to […]

Continue reading


SPOJ: PRIME1 – Prime Generator

Problem Link http://www.spoj.com/problems/PRIME1/ Problem Description In this problem, We need to print all the prime numbers between two given values m and n. Concepts Used This problem is based on prime sieve(Sieve of Eratosthenes). Code #include<stdio.h> void sieve(long long int,long long int,bool[],bool[]); int main() { long long int m,n; int t; /*scan number of test […]

Continue reading


Translation of a Line

Translation of line comes under the category of geometric transformations.In geometric transformations,the object is transformed relative to a stationary coordinate system or background.In 2D translation,the object is displaced along x and y direction and magnitude of displacement is specified by translation parameters tx and ty. In order to perform a sequence of transformations(translation,scaling,rotation or reflection) […]

Continue reading


Boundary-Fill Algorithm

Boundary-fill algorithm is used for region filling when the region is boundary-defined i.e. pixels having colour equal to boundary_col comprise the boundary of region.This algorithm starts with a seed pixel inside the region which is the starting point for the recursive algorithm. The algorithm checks to see if pixel is boundary pixel(defined by boundary_col) or […]

Continue reading