求最大公约数
来源:互联网 发布:maxwell软件 百科 编辑:程序博客网 时间:2024/05/21 04:01
<pre name="code" class="cpp">//求x和y的最大公约数 x<y//辗转相除法O(log(n))int susu(int x, int y){if(x>y){int t = x;x = y;y = t;}if(x==0){return y;}return susu(y%x, x);}//暴力搜索O(n)int susu1(int x, int y){if(x>y){int t = x;x = y;y = t;}int result = 1;for(int i=1; i<=x ;i++){if(x%i==0 && y%i==0){result = i;}}return result;}
0 0
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- 求最大公约数
- linux top命令详解
- android 中CoordinatorLayout有什么作用
- linux应用程序:键盘双击与长按识别及串口通讯
- 利用Python 破解类unix系统 /etc/shadow 文件hashed password
- java中回调函数的实现
- 求最大公约数
- Android版本和API Level对应关系从1.0到6.0
- popwindow 挡住 魅族手机虚拟按键
- LINUX下ECHO命令详解---待完善
- 通过SQL Server代理启动Windows服务
- struts中的感叹号方式动态方法调用
- BZOJ_P3262 陌上花开(CDQ分治+树状数组)
- 动态改变listview的高度
- echo命令详解