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