uva 10193 All You Need Is Love
2013-05-23 10:55
537 查看
将两个2进制的数转换成10进制的数,然后看俩数是否互质,即最大公约数是否为1.
#include <iostream> #include<cstring> #include<cmath> #include<cstdio> using namespace std; char s1[33],s2[33]; int gcd(int a,int b) { if(b==0) return a; return gcd(b,a%b); } int tonum(char s[]) { int len=strlen(s); int sum=0; for(int i=len-1,j=0;i>=0;i--,j++) sum+=(s[i]-'0')*pow(2,j); return sum; } int main() { int n; cin>>n; int num=1; getchar(); while(n--) { gets(s1); gets(s2); int num1,num2; num1=tonum(s1); num2=tonum(s2); if(num1<num2) swap(num1,num2); cout<<"Pair #"<<num++<<": "; if(gcd(num1,num2)!=1) cout<<"All you need is love!"<<endl; else cout<<"Love is not all you need!"<<endl; } return 0; }
相关文章推荐
- UVa 10193 All You Need Is Love 求互质 数学题
- UVa 10193 - All You Need Is Love
- 谷歌机器翻译Attention is All You Need
- 【论文阅读】Attention Is All You Need
- Attention Is All You Need
- 对Attention is all you need 的理解
- 《Attention is All You Need》浅读(简介+代码)
- [ICLR2016]All You Need is a Good Init
- Attention Is All You Need 论文阅读笔记
- 模型汇总16 各类Seq2Seq模型对比及《Attention Is All You Need》中技术详解
- Attention is all you need阅读笔记
- [深度学习论文笔记][Weight Initialization] All you need is a good init
- Attention is all you need 论文记录
- 《Attention is All You Need》浅读(简介+代码)
- Attention is all you need新翻译架构的测试
- 一文读懂「Attention is All You Need」| 附代码实现
- 一文读懂「Attention is All You Need」| 附代码实现
- Attention Is All You Need
- 论文阅读笔记之Attention Is All You Need
- 在Linux中编译文件是出现 Your intltool is too old. You need intltool 0.35.0 or later的问题怎么解决