Physical Education Lesson - Codeforces 1928C

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <set> using namespace std; set<int> s; int main() { int t; cin >> t; while (t--) { int n,x; cin >> n >> x; s.clear(); for (int i = 1;i * i <= n - x;i++) { if (!((n - x) % i)) { if (!(i & 1) && (i >> 1) + 1 >= x) { s.insert(i); } if (!(((n - x) / i) & 1) && (((n - x) / i) >> 1) + 1 >= x) { s.insert((n - x) / i); } } } for (int i = 1;i * i <= n + x - 2;i++) { if (!((n + x - 2) % i)) { if (!(i & 1) && (i >> 1) + 1 >= x) { s.insert(i); } if (!(((n + x - 2) / i) & 1) && (((n + x - 2) / i) >> 1) + 1 >= x) { s.insert((n + x - 2) / i); } } } cout << s.size() << '\n'; } return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines