Codeforces Round #594 (Div. 2)

Contest Info


[Practice Link](https://codeforces.com/contest/1248)
Solved A B C D1 D2 E F
4/7 O O O O - - -
  • O 在比赛中通过
  • Ø 赛后通过
  • ! 尝试了但是失败了
  • - 没有尝试

Solutions


A. Integer Points

题意:
(A)给出(n)条直线,形式为(y = x + p_i), (B)给出(m)条直线,形式为(y = -x + q_i)
问有多少个二元组((i, j)),使得(i)表示(A)的直线,(j)表示(B)的直线,并且这两条直线有整数交点。

思路:
考虑两条直线的交点(x + p_i = -x + q_i),那么(x = frac{q_i - p_i}{2})
那么(p_i, q_i)的奇偶性要相同才可以。

代码:

view code
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define fi first
#define se second
#define endl "
" 
using namespace std;
using db = double;
using ll = long long;
using ull = unsigned long long; 
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; while (x >= mod) x -= mod; while (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }  
#define dbg(x...) do { cout << "