Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <string>
- #include <cstring>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- int main()
- {
- int x0, y0, r, x1, y1, x2, y2, a, b, c, ans = 0;
- ld yy, xx;
- cin >> x0 >> y0 >> r >> x1 >> y1 >> x2 >> y2;
- a = y2 - y1;
- b = -(x2 - x1);
- c = -a * x1 - b * y1;
- if(x1 == x2)
- {
- for(int i = -r; i <= r; i++)
- {
- yy = (-b * (y0 + i) - c) / a;
- if((ll)yy == yy && (yy >= x0 - r && yy <= x0 + r)) ans++;
- }
- }
- else
- {
- for(int i = -r; i <= r; i++)
- {
- xx = (-a * (x0 + i) - c) / b;
- if((ll)xx == xx && (xx >= y0 - r && xx <= y0 + r)) ans++, cout << i << " ";
- }
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement