uva 10193All You Need Is Love
来源:互联网 发布:淘宝如何修改店铺名 编辑:程序博客网 时间:2024/04/30 18:25
将两个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 10193All You Need Is Love
- 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阅读笔记
- 对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 论文阅读笔记
- All of you need it
- Maven contain all you need
- Love (is) Actually (All Around...)
- One thing you need to understand about this detox diet is that like all detox diets
- [深度学习论文笔记][Weight Initialization] All you need is a good init
- 解决VS2008中CHtmlView函数OnBeforeNavigate2不能禁止跳转的BUG
- C# SHMultiFileProperties查看多个文件属性
- 【CDC翻客】如何做一款成功的应用(下)
- Java内部类总结 (吐血之作)
- 使用HIVE的WEB界面:HWI
- uva 10193All You Need Is Love
- 作为一个程序员,俺的核心竞争力是什么
- <meta name="viewport" content="width=device-width
- poj2250-打印单一LCS路径。
- Product manager interview questions
- android handler 更详解
- SQL中复制一个表到另外一个数据库中
- wicket常见问题
- VC中CList用法