UVa 10193 - All You Need Is Love
来源:互联网 发布:大数据薪资待遇 编辑:程序博客网 时间:2024/05/21 10:53
题目:判断两个2进制的串是否互质。
分析:数论。首先,将两数装化成十进制;然后,计算gcd即可。
说明:好几天没刷题了╮(╯▽╰)╭,有点不习惯。
#include <iostream>#include <cstdlib>#include <cstdio>using namespace std;char buf[32];int gcd( int a, int b ){return (a%b)?gcd(b,a%b):b;} int main(){int n,A,B;while ( scanf("%d",&n) != EOF ) for ( int i = 1 ; i <= n ; ++ i ) {scanf("%s",buf);A = 0;for ( int j = 0 ; buf[j] ; ++ j ) {A <<= 1;A += buf[j]-'0';}scanf("%s",buf);B = 0;for ( int j = 0 ; buf[j] ; ++ j ) {B <<= 1;B += buf[j]-'0';}printf("Pair #%d: ",i);if ( gcd( A, B ) != 1 )printf("All you need is love!\n");else printf("Love is not all you need!\n");}return 0;}
0 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
- Linux命令exit - 退出当前shell
- HDOJ题目2086 A1 = ?(数学)
- .net mvc 微信开发笔记(五)------JSON解析,自定义菜单
- Oracle GoldenGate环境中主库和备库 网络突然中断后,主端的dp进程无法启动的问题
- 黑马程序员_JavaBean
- UVa 10193 - All You Need Is Love
- 忘记密码
- 图表控件TeeChart干货分享(绘制2D、3D实时曲线---VC++示例源代码--网络首发)
- POJ 3185 The Water Bowls(高斯消元,枚举变元)
- Swift初见
- 2012年9月15日锐捷网络嵌入式研发笔试
- HDU 3635 Dragon Balls 七龙珠 Union Find算法
- Android 高手进阶之自定义View,自定义属性(带进度的圆形进度条)
- Python查找文件内容