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.

Thanks in advance.

# | User | Rating |
---|---|---|

1 | tourist | 3532 |

2 | Radewoosh | 3434 |

3 | wxhtxdy | 3425 |

4 | Benq | 3368 |

5 | ecnerwala | 3301 |

6 | mnbvmar | 3280 |

7 | LHiC | 3276 |

8 | maroonrk | 3199 |

9 | yutaka1999 | 3190 |

10 | TLE | 3145 |

# | User | Contrib. |
---|---|---|

1 | Errichto | 192 |

2 | Radewoosh | 178 |

3 | tourist | 173 |

4 | antontrygubO_o | 167 |

4 | Vovuh | 167 |

4 | PikMike | 167 |

7 | rng_58 | 159 |

8 | majk | 157 |

9 | Um_nik | 152 |

9 | farmersrice | 152 |

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.

Thanks in advance.

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.

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.

```
#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

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.

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Nov/22/2019 09:49:37 (e2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|