kazama460's blog

By kazama460, history, 3 weeks ago, In English,

I am practicing Mo's algorithm and this is my third problem on it , i tried to optimize but could not go further , I need you guys help. I have solved this problem using Segment Tree , but getting TLE with Mo's.

Problem Link

Solution Link

Thanks in advance.

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By kazama460, history, 5 months ago, In English,

i have been studying mobius inversion from last 1 week , and i have came across this beautiful article on it but i am not able to understand that how eq.3 is transformed into eq.4

Here is the link to the article.

please help me if you can , i have spent a lot of time to understand it.

Thank you.

Read more »

 
 
 
 
  • Vote: I like it
  • -3
  • Vote: I do not like it

By kazama460, history, 17 months ago, In English,

i am stuck at simple problem , and the problem is that there is no Editorial available for this problem.

The problem is as follows:

Given M (Distinct) integers A1 , A2 , A3 , A4 , A5 ...... , Am , find all integers K , such that remainder of all elements with k is same I.E. A1%K = A2%K = A3%K = ..... = Am%K

and K>1.

Number of elements are 100 , and Ai <= 10^9

My solution is brute force: i am running a loop from 2 to second largest element (which can be upto 10^9) and finding all k , but its giving TLE.

This is the link to the problem

any hint or help would be appreciative. Thanks in advance and happy coding.

Read more »

 
 
 
 
  • Vote: I like it
  • +2
  • Vote: I do not like it

By kazama460, history, 19 months ago, In English,

I am trying to solve a problem on convex hull(my first problem on convex hull) , but don't know why getting WA. I am using Grahm's scan algo to generate all points of Hull , and then simply calculating the parameter of the hull. please can anyone tell me whats wrong with my code. thank you in advance.

Link to my code

Link to problem

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By kazama460, history, 2 years ago, In English,
#include<bits/stdc++.h>
using namespace std;

int main()
{
	float x1,x2,y1,y2,x3,y3,x4,y4,ansx,ansy;
	
	while(cin>>x1>>y1)
	{
		cin>>x2>>y2>>x3>>y3>>x4>>y4;
		
		if(x1==x3 && y1==y3)
		{
			ansx = x2-x1+x4;
			ansy = y2-y1+y4;
		}
		
		else
		if(x2==x3 && y2==y3)
		{
			ansx = x1-x2+x4;
			ansy = y1-y2+y4;
		}
		else
		if(x1==x4 && y1==y4)
		{
			ansx = x2-x1+x3;
			ansy = y2-y1+y3;
		}
		
		else
		{
			ansx = x1-x2+x3;
			ansy = y1-y2+y3;
		}
		printf("%.3lf %.3lf\n", ansx, ansy);
	}
}

i dont know whats wrong with code , getting wrong answer. if anyone can point out some problem in the code. thank you in advance. Link to problem

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By kazama460, history, 2 years ago, In English,

Hola guys , i have just started learning about graph theory , can somebody give links to some easy questions to practice for the following topics(easy ones please , as i have just started :) )

1-> graph representation(both adjacency matrix and adjacency list). 2-> dfs and bfs.

and your advice are always welcome about how should i progress learning graph theory.

thank you in advance.

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By kazama460, history, 2 years ago, In English,

hey there , i was trying to solve UVA problem (UVA 10106 ) and my code seems to work fine for the test cases but dont know why i am getting wrong answer. Link to my code , can anyone point out the problem or a test case for which my code fails. thank you in advance.

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it