Math Sheet
Math Sheet
<Given three numbers L, rand M Print the product of all numbers from L to R module M>
long long l, r, m;
----------------------------------------
<Given three points on the Cartesian plane. Determine if 1 straight can pa >
float x1 , x2 , x3 , y1 , y2 , y3 ;
double ans = (x2 -x1) * (y3- y1) -(y2 -y1)* (x3 - x1) ;
if (ans == 0) {
else {
----------------------------------------
<Given two lines L1 and Determine whether they are parallel or not>
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
if (ans == 0 ) {
}
else {
--------------------------------------
<Given 2 Cartesian points (X1, Y1) and (X2, Y2). Print the distance between the two points>
--------------------------------------
float a[3] ;
a[3] = 1500 ;
else {
----------------------------------------
a number R donates radius of the circle and a number N donates number of points coordinates
double x1 , y1 , r , t ;
double x2 , y2 ;
if (distance > r ) {
else {
----------------------------------------
<Given a number N. Print the prime factors of N in the following form: (P1)x * (P2)y...>
int n ;
cin >> n ;
while (n%i==0) {
n= n/i ;
freq[i] ++; }
if (n!=1) {
freq[n] ++;
bool tm = 0;
if (freq[i]>0) {
if (tm==1) {
cout <<"*"<< "(" << i << "^" << freq[i] << ")" ;
}
else {cout << "(" << i << "^" << freq[i] << ")" ;
tm = 1 ;
}}}
---------------------------------------
int cof = 1 ;
cof = cof*(i-j) /j ;
---------------------------------------
<Given two numbers and S that donate radius of a circle and side length of a square.
double r , s ;
if ( arear > arear2 && r2 < r && areas < arear && dia<=r*2 ) {
---------------------------------------------
and (x4,y4)
,With two sides parallel to the Y-axis and the other two parallel to the X-axis and N
points, for each point check whether it belongs to the rectangle or not.>
int q ;
cin>> q ;
while (q--) {
else {
------------------------------------------------
<Given four cartesian points (X1, Y1), (X2, Y2), (X3, Y3) and (X4, Y4) that
double x1 , y1 , x2 , y2 ;
else {
-------------------------------------------------------------------
int n ;
cin >> n ;
double d = 0 ;
d += log10(i) ;
cout << "Number of digits of " << n << "! is " << floor(d) +1 ;
----------------------------------------------
<Given two numbers Aand B Print NCR and NPR of A and B A≥B >
if(i<=ab)
factab*=i; }
if(i<=b)
factb*=i; }
facta*=i; }
----------------------------------------------------
<Given 2 numbers A and B print 3 lines summation of all numbers between A and B (inclusive).
summation of even numbers between A and B (inclusive).summation of odd numbers between
A and B (inclusive)>
long long a,b;
cin >> a >> b;
long long mn=min(a,b),mx=max(a,b);
a=mn; b=mx;
long long sum=((b*(b+1))/2)-((a*(a-1))/2);
a--;
long long even=((b/2)*((b/2)+1))-((a/2)*((a/2)+1));
long long odd=sum-even;
cout << sum << "\n"<< even << "\n" odd;