Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <cmath>
- using namespace std;
- int main() {
- int b, j;
- cin >> b >> j;
- map<int, int> m;
- for(int i = 1; i <= sqrt(b); i++) {
- if(b % i == 0) {
- m[i]++;
- if(i != b / i) {
- m[b / i]++;
- }
- }
- }
- int result = 0;
- for(int i = 1; i <= sqrt(j); i++) {
- if(j % i == 0) {
- m[i]++;
- if(m[i] == 2) {
- result++;
- }
- if(i != j / i) {
- m[j / i]++;
- if(m[j / i] == 2) {
- result++;
- }
- }
- }
- }
- cout << result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement