[大数GCD Stein算法] BZOJ 1876 [SDOI2009]SuperGCD
2016-07-16 17:44
387 查看
懒得写高精
python水过
<span style="font-family:Microsoft YaHei;font-size:14px;color:#330099;">a=(int)(input())
b=(int)(input())
while b!=0:
t=a
a=b
b=t%b
print a </span>
Stein 算法
只有减法和位移
<span style="font-family:Microsoft YaHei;font-size:14px;color:#330099;">a=(int)(input())
b=(int)(input())
c=0
while (a!=0 and b!=0):
x=a&1;y=b&1
if (x==0 and y==0):
a>>=1;b>>=1;c=c+1
elif (x==0):
a>>=1
elif (y==0):
b>>=1
elif (a>b):
a-=b
else:
b-=a;
while (c!=0):
a<<=1;c=c-1
print a
</span>
python水过
<span style="font-family:Microsoft YaHei;font-size:14px;color:#330099;">a=(int)(input())
b=(int)(input())
while b!=0:
t=a
a=b
b=t%b
print a </span>
Stein 算法
只有减法和位移
<span style="font-family:Microsoft YaHei;font-size:14px;color:#330099;">a=(int)(input())
b=(int)(input())
c=0
while (a!=0 and b!=0):
x=a&1;y=b&1
if (x==0 and y==0):
a>>=1;b>>=1;c=c+1
elif (x==0):
a>>=1
elif (y==0):
b>>=1
elif (a>b):
a-=b
else:
b-=a;
while (c!=0):
a<<=1;c=c-1
print a
</span>
相关文章推荐
- “无限加载更多”带来的移动端性能瓶颈
- Ubuntu 14.04数据库服务器--mysql的安装和配置
- .net索引器
- Dalvik虚拟机【3】——类加载
- [python]百度语音rest api
- 矩形覆盖
- 深入理解l内核v4l2框架之video for linux 2
- 谈谈神奇的iframe
- Android PopupWindow的使用和分析
- RecyclerView.Adapter的优化与封装
- aemon 进程为什么要fork两次,与后台运行程序区别?
- [原创]java WEB学习笔记45:自定义HttpFilter类,理解多个Filter 代码的执行顺序,Filterdemo:禁用浏览器缓存的Filter,字符编码的Filter,检查用户是否登陆过的Filter
- 算法--判断字符串是不是数字
- 史上最全 | 前端工程师面试题汇总
- [数学 九余数定理] HDU 1163 Eddy's digital Roots
- call ntdll.RtlUnicodeStringToAnsiString
- 学习Dialog(一)------基础
- vector中v[i]和v.at(i)的区别
- Extjs的onReady方法
- 数组 字符串遍历