https://www.hackerrank.com/contests/w7/challenges/die-hard-3

首先,发现c <= max(a, b) 而且 c = aX + bY时有解。然后根据扩展欧几里得算法知道c % gcd(a, b) == 0时有解。

#include <vector>
#include <iostream> using namespace std; int gcd(int a, int b) {
if (a % b == 0) {
return b;
} else {
return gcd(b, a % b);
}
} int main() {
int T;
cin >> T;
while (T--) {
int a, b, c;
cin >> a >> b >> c;
int r = gcd(a, b);
if (c % r == 0 && c <= max(a, b)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}

  

*[hackerrank]Die Hard 3的更多相关文章

  1. No zuo no die:DDD 应对具体业务场景,Domain Model 重新设计

    写在前面 上联:no zuo no die why you try 下联:no try no high give me five 横批: let it go上联:no zuo no die why y ...

  2. 日常小测:颜色 && Hackerrank Unique_colors

    题目传送门:https://www.hackerrank.com/challenges/unique-colors 感谢hzq大神找来的这道题. 考虑点分治(毕竟是路经统计),对于每一个颜色,它的贡献 ...

  3. Also unsere eigene Christian Louboutin Webshop bietet die überragende Christian Louboutin Schuhe uk schiebt zusammen mit kostengünstigen Wert

    www.heelschuhe.de, Es ist wirklich eine der Frauen erfordern immer interessant und auch Louboutin Pu ...

  4. php的exit和die

    首先, 两者是相等的: exit is equivalent to die; 其次, 都是语言构造器, language construct. 不是函数! 后面的内容用括号括起来只是为了方便... 用 ...

  5. IE6 Must Die

    最近 Twitter 上很多人在推一个名为 IE6 Must Die 的活动, 参与的朋友可以通过头像转换服务在自己的头像上加上一个禁止 IE6 的图标, 很是拉风. Internet Explore ...

  6. HackerRank "Square Subsequences" !!!

    Firt thought: an variation to LCS problem - but this one has many tricky detail. I learnt the soluti ...

  7. HackerRank "Minimum Penalty Path"

    It is about how to choose btw. BFS and DFS. My init thought was to DFS - TLE\MLE. And its editorial ...

  8. HackerRank "TBS Problem" ~ NPC

    It is marked as a NPC problem. However from the #1 code submission (https://www.hackerrank.com/Charl ...

  9. (译)开发优秀的虚拟现实体验:从开发I Expect You to Die中总结的六个要点

    这篇文章是我从网上找来的,我觉得他非常详细的解释了VR发展的需求和必要.我认为通过这篇文章可以让大家了解VR. 译者写在最前: 来到追光动画有好几个月了,抱歉这段时间也没有什么文章与大家分享,我现在在 ...

随机推荐

  1. SQL允许远程访问

    1.打开sqlserver对象资源管理器 右键 方面 常规 服务器配置 RemoteAccessEnabled true RemoteDacEnabled  true 2.打开SQL SERVER管理 ...

  2. WordPress 主题开发 - (三) 开发工具 待翻译

    Before we get started building any WordPress Theme, we’re going to need to get our development tools ...

  3. 跟着PHP100第一季学写一个CMS(11-20)

    PS.刚发现IE并不兼容,有点悲剧  cms1.1密码处理 1.小知识:sha1($_answer) //加密为40位,不知道能不能破解 2.小知识:mysql_real_escape_string( ...

  4. Oracle bbed使用说明1

    一.centos上编译安装BBED工具 [orasrv@localhost ~]$ cd $ORACLE_HOME/rdbms/lib [orasrv@localhost ~]$ make -f in ...

  5. impdp ORA-29913: error in executing ODCIEXTTABLEOPEN callout

    1.数据导出时的日志 ;;; Export: Release :: Copyright (c) , , Oracle and/or its affiliates. All rights reserve ...

  6. [Environment Build] 如何实现Visual Studio中的区域语言环境切换

    最开始学习C#这门语言的时候,英文能力不够好,安装的中文版本的Visual Studio,现在工作有段时间了,公司又是个外企,慢慢不习惯中文版本的了,于是产生了想切换语言的想法,网上搜索了下,下载了个 ...

  7. python之域与属性

    python, javascript中域与属性是二个不同的概念, 域就是变量, 而属性则是符合某些约束, 例如getter, setter...等的特殊"变量". python中使 ...

  8. andriod

    谷歌提供的安卓源码中,网址如下:http://androidxref.com http://blog.csdn.net/zoe6553/article/details/6622258

  9. Python实战(1)

    此次实战完全按照Python教程 - 廖雪峰的官方网站进行 首先下载windows版本的Python2.7,附上下载链接http://www.python.org/ftp/python/2.7.6/p ...

  10. Wireshark 入门

    1.过滤目的地是百度的IP包. 百度的ip: 命令:ip.src eq 61.135.169.125 过滤ip来源是61.135.169.125 ip.dst eq 61.135.169.125 过滤 ...