Fractions Again?!
程序员文章站
2022-06-08 12:24:14
...
这题就是直接暴搜,代码如下
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
while(cin>>n){
int a[10010],b[10010];
int i=0,j,x,y;
for(y=n+1;y<=2*n;y++){
if((y*n)%(y-n)==0){
x=(n*y)/(y-n);
a[i]=x;
b[i++]=y;
}
}
cout<<i<<endl;
for(j=0;j<i;j++)
cout<<"1/"<<n<<" = "<<"1/"<<a[j]<<" + "<<"1/"<<b[j]<<endl;
}
return 0;
}
上一篇: LeetCode187.重复的DNA序列
推荐阅读
-
1086 Tree Traversals Again (25 分)(二叉树的遍历)
-
HDU 1848 Fibonacci again and again(SG函数)
-
Repeat Again
-
【STL队列和栈】HDU-1702 ACboy needs your help again!
-
HDU 1702 ACboy needs your help again!(栈和队列的简单应用)
-
Ubuntu20.04 SSH无法登陆root用户 Permission denied, please try again
-
CodeForces - 1089F Fractions (同余方程,互质数)
-
先锋111XL刻录显示QUEUE AGAIN LATER的解决
-
pat 1086 Tree Traversals Again
-
PATA 1086 Tree Traversals Again