A. Ebony and Ivory

题目连接:

http://www.codeforces.com/contest/633/problem/A

Description

Dante is engaged in a fight with "The Savior". Before he can fight it with his sword, he needs to break its shields. He has two guns, Ebony and Ivory, each of them is able to perform any non-negative number of shots.

For every bullet that hits the shield, Ebony deals a units of damage while Ivory deals b units of damage. In order to break the shield Dante has to deal exactly c units of damage. Find out if this is possible.

Input

The first line of the input contains three integers a, b, c (1 ≤ a, b ≤ 100, 1 ≤ c ≤ 10 000) — the number of units of damage dealt by Ebony gun and Ivory gun, and the total number of damage required to break the shield, respectively.

Output

Print "Yes" (without quotes) if Dante can deal exactly c damage to the shield and "No" (without quotes) otherwise.

Sample Input

4 6 15

Sample Output

No

Hint

题意

给你 a,b,c

问你能够使用若干个a和若干个b,恰好组成c

题解:

暴力枚举一个,然后O(1)算另外一个就好了

代码

#include<bits/stdc++.h>
using namespace std; int main()
{
long long a,b,c;
cin>>a>>b>>c;
for(int i=0;i<=100000;i++)
{
long long res = c - a*i;
if(res==0)return puts("Yes");
if(res<0)break;
long long p = res/b;
if(p*b==res)
return puts("Yes");
}
return puts("No");
}

Manthan, Codefest 16 A. Ebony and Ivory 水题的更多相关文章

  1. Manthan, Codefest 16 -A Ebony and Ivory

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  2. Manthan, Codefest 16

    暴力 A - Ebony and Ivory import java.util.*; import java.io.*; public class Main { public static void ...

  3. Manthan, Codefest 16 D. Fibonacci-ish

    D. Fibonacci-ish time limit per test 3 seconds memory limit per test 512 megabytes input standard in ...

  4. Manthan, Codefest 16(B--A Trivial Problem)

    B. A Trivial Problem time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  5. Manthan, Codefest 16 -C. Spy Syndrome 2

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  6. CF Manthan, Codefest 16 G. Yash And Trees 线段树+bitset

    题目链接:http://codeforces.com/problemset/problem/633/G 大意是一棵树两种操作,第一种是某一节点子树所有值+v,第二种问子树中节点模m出现了多少种m以内的 ...

  7. CF #Manthan, Codefest 16 C. Spy Syndrome 2 Trie

    题目链接:http://codeforces.com/problemset/problem/633/C 大意就是给个字典和一个字符串,求一个用字典中的单词恰好构成字符串的匹配. 比赛的时候是用AC自动 ...

  8. CF Manthan, Codefest 16 B. A Trivial Problem

    数学技巧真有趣,看出规律就很简单了 wa 题意:给出数k  输出所有阶乘尾数有k个0的数 这题来来回回看了两三遍, 想的方法总觉得会T 后来想想  阶乘 emmm  1*2*3*4*5*6*7*8*9 ...

  9. Manthan, Codefest 16 H. Fibonacci-ish II 大力出奇迹 莫队 线段树 矩阵

    H. Fibonacci-ish II 题目连接: http://codeforces.com/contest/633/problem/H Description Yash is finally ti ...

随机推荐

  1. perl HTML::LinkExtor模块(1)

    use LWP::Simple; use HTML::LinkExtor; $html = get("http://www.baidu.com"); $link = HTML::L ...

  2. Centos7编译安装Xen环境(vtpm)

    编译xen环境(http://www.lvtao.net/server/574.html#comment-1882): yum update yum groupinstall "Develo ...

  3. barrier 和 preempt_disable() 学习【转】

    #define preempt_disable() \ do{ \ inc_preempt_count(); \ barrier();    \ }while(0) 一.这个barrier 在干什么. ...

  4. python爬虫模块之HTML解析模块

    这个就比较简单了没有什么好强调的,如果返回的json 就是直接按照键值取,如果是网页就是用lxml模块的html进行xpath解析. from lxml import html import json ...

  5. vs 预编译命令行

    xcopy "$(SolutionDir)\Transight_FY_DataExchange_UI\CuscapiUpdaterServer.xml"  /i /d /y

  6. 坐标转换——GCJ-02

    WGS84(World Geodetic System 1984),是为GPS 全球定位系统 使用而建立的坐标系统GCJ-02,我国在WGS84的基础上加密得到BD-09,百度坐标在GCJ-02基础上 ...

  7. python初学-列表

    列表操作: 列表一般需要先调用方法后才能打印,不能直接打印调用的方法 因为列表可以修改 一般不会返回一个新列表 # 列表 # new_names = ['lzc','lzc2','lzc3'] # 下 ...

  8. POJ 1733 Parity game(带权并查集)

    题目链接:http://poj.org/problem?id=1733 题目大意:给你m条信息,每条信息告诉你区间l~r的1的个数是奇数还是偶数,如果后面出现信息跟前面矛盾则这条信息是错误的,问在第一 ...

  9. 常用SQL时间格式SQLServer中文版的默认的日期字段datetime格式是yyyy-mm-d

    常用SQL时间格式 SQL Server中文版的默认的日期字段datetime格式是yyyy-mm-dd Thh:mm:ss.mmm 例如: select getdate() -- ::08.177 ...

  10. hdu 1430(BFS+康托展开+映射+输出路径)

    魔板 Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...