A题

#include <bits/stdc++.h>
using namespace std;
int main () {
int t;
cin >> t;
while(t--) {
int n, x;
cin >> n >> x;
int ans = 0;
for(int i = 0; i < n; ) {
i = ans * x + 2;
ans++;
}
cout << ans << endl;
}
}
B题

#include <bits/stdc++.h>
using namespace std;
int main () {
int t;
cin >> t;
while(t--) {
bool ok = 0;
int n, m;
cin >> n >> m;
for(int i = 0; i < n; ++i) {
int x1, x2, y1, y2;
cin >> x1 >> x2 >> y1 >> y2;
if(x2 == y1) {
ok = 1;
}
}
if(ok && m % 2 == 0) {
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
}
}