-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoi1751.cpp
More file actions
58 lines (55 loc) · 925 Bytes
/
Copy pathnoi1751.cpp
File metadata and controls
58 lines (55 loc) · 925 Bytes
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
52
53
54
55
56
57
58
/**
* Number:noi1751
* Title:分解因数
* Status:AC
* Tag:[dfs]
**/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
int factor[200],flen;
int ans;
void dfs(int pre,int remain)
{
// printf("%d %d\n",pre,remain);
if(remain==1)
{
ans++;
return;
}
for(int i=pre;i<flen;i++)
{
if(remain%factor[i]!=0)continue;
if(factor[i]>remain)return;
dfs(i,remain/factor[i]);
}
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n;
scanf("%d",&n);
flen=0;
for(int i=2;i<=n;i++)
{
if(n%i==0)
{
factor[flen++]=i;
}
}
ans=0;
dfs(0,n);
printf("%d\n",ans);
}
return 0;
}