Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define ld long double
- #define pb push_back
- #define p_b pop_back
- #define si stack<int>
- #define sll stack<ll>
- #define sc stack<char>
- #define vi vector<int>
- #define vll vector<ll>
- #define mii map<int, int>
- #define msi map<string, int>
- #define mci map<char, int>
- #define qc queue<char>
- #define qi queue<int>
- #define qll queue<ll>
- using namespace std;
- int hcf(int a, int b){
- int rem = 1;
- while(true){
- rem = a%b;
- if(rem == 0){
- break;
- }
- a = b;
- b = rem;
- }
- return b;
- }
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int t;
- cin >> t;
- vector<pair<ll, ll>> v;
- while(t--){
- ll m, c;
- cin >> m >> c;
- v.pb({m, c});
- }
- ll count = 0;
- set<pair<string, string>> s;
- for(int i = 0; i < v.size()-1; i++){
- for(int j = i+1; j < v.size(); j++){
- int m1 = v[i].first, c1 = v[i].second, m2 = v[j].first, c2 = v[j].second;
- if(m1 != m2){
- string x, y;
- x = to_string(abs((c2-c1)/hcf(c1-c2, m1-m2)))+'/'+to_string(abs((m1-m2)/hcf(c1-c2, m1-m2)));
- y = to_string(abs((m1*c2-m2*c1)/hcf(m1*c2-m2*c1, m1-m2)))+'/'+to_string(abs((m1-m2)/hcf(m1*c2-m2*c1, m1-m2)));
- if((c1-c2 < 0 && m1-m2 > 0) || (c1-c2 > 0 && m1-m2 < 0)){
- x = '-'+x;
- }
- if((m1*c2-m2*c1 < 0 && m1-m2 > 0) || (m1*c2-m2*c1 > 0 && m1-m2 < 0)){
- y = '-'+y;
- }
- if(c2-c1 == 0){
- x = "0";
- }
- if(m1*c2-m2*c1 == 0){
- y = "0";
- }
- s.insert({x, y});
- }
- }
- }
- cout << s.size() << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement