Codeforces Round #282 (Div. 2) 495B. Modular Equations Solution
Problem Link : https://codeforces.com/contest/495/problem/B
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, t, i, j, a, b, df;
cin >> a >> b;
if (a == b)
cout << "infinity" << endl;
else {
df = abs(a - b);
ll ans = 0;
for (i = 1; i * i <= df; i++) {
if (df % i == 0) {
if (i > b)
ans++;
if (df / i != i && (df / i) > b)
ans++;
}
}
cout << ans << endl;
}
}
No comments