-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathPossibleGCD.cpp
51 lines (46 loc) · 1.26 KB
/
PossibleGCD.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<bits/stdc++.h>
using namespace std;
void solution(){
int a,b;
cin>>a>>b;
int temp = abs(a-b);
int ans=0;
for(int i=1;i<=sqrt(temp);i++){
if(temp%i==0){
if(temp/i==i){ ans++; }
else{ ans+=2; }
}
}
cout<<ans<<endl;
/*
class Solution {
public:
int numRollsToTarget(int n, int k, int target) {
int MOD = 1000000007;
vector<vector<int>> dp(n, vector<int>(target + 1, 0));
// last dice, only one face can sum up to remain
for (int i = 1; i <= min(k, target); i++) {
dp[n - 1][i] = 1;
}
for (int dice = n - 2; dice >= 0; dice--) {
for (int remain = 1; remain <= target; remain++) {
for (int i = 1; i <= min(k, remain); i++) {
// current dice roll i and next dices roll remain - i
dp[dice][remain] += dp[dice + 1][remain - i];
dp[dice][remain] %= MOD;
}
}
}
return dp[0][target];
}
};
*/
}
int main(){
int test;
cin>>test;
while(test--){
solution();
}
return 0;
}