UVA10976

暴力枚举,大胆模拟。

 1 #include <iostream>
 2 #include <cstring>
 3 #include <string>
 4 #include <map>
 5 #include <set>
 6 #include <algorithm>
 7 #include <fstream>
 8 #include <cstdio>
 9 #include <cmath>
10 #include <stack>
11 #include <queue>
12 using namespace std;
13 const double Pi=3.14159265358979323846;
14 typedef long long ll;
15 const int MAXN=5000+5;
16 const int dx[5]={0,0,0,1,-1};
17 const int dy[5]={1,-1,0,0,0};
18 const int INF = 0x3f3f3f3f;
19 const int NINF = 0xc0c0c0c0;
20 const ll mod=1e9+7;
21 int a[100];
22 struct node{
23     int x,y;
24     node (int x=0,int y=0) :x(x),y(y) {}
25 };
26 int main()
27 {
28     int k;int cnt=0;
29     while(cin>>k)
30     {    
31         int cnt=0;ll b=k+1;
32         vector <node> V;
33         while(1)
34         {
35             double a=b*k*1.0/(b-k);
36             if(a<b) break;
37             if((int)a==a) 
38             {
39                 cnt++;
40                 V.push_back(node(a,b));
41             } 
42             b++;
43         }
44         cout<<cnt<<endl;
45         for(int i=0;i<V.size();i++)
46         {
47             printf("1/%d = 1/%d + 1/%d\n",k,V[i].x,V[i].y);
48          } 
49     }
50     return 0;
51  } 

猜你喜欢

转载自www.cnblogs.com/Msmw/p/10639959.html