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. java===java基础学习(4)---字符串操作

    java中的字符串操作和python中的大致相同,需要熟悉的就是具体操作形式. 关于具体api的使用,详见:java===字符串常用API介绍(转) package testbotoo; public ...

  2. 【模板】BZOJ 1692:队列变换—后缀数组 Suffix Array

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1692 题意: 给出一个长度为N的字符串,每次可以从串头或串尾取一个字符,添加到新串中,使新串 ...

  3. 0x3F3F3F3F——ACM中的无穷大常量

    在算法竞赛中,我们常常需要用到设置一个常量用来代表“无穷大”. 比如对于int类型的数,有的人会采用INT_MAX,即0x7fffffff作为无穷大.但是以INT_MAX为无穷大常常面临一个问题,即加 ...

  4. (转)opencv 代替caffe.io.load_image

    self.net.blobs[, , self.image_resize, self.image_resize) #image = caffe.io.load_image(image_file) im ...

  5. Kettle提高输入输出数据总结

    1 mysql在数据连接是可以通过设置一下三个三处的方式 useServerPrepStmts=false       useCursorFetch=true      useCompression= ...

  6. Memcached内存缓存技术

    Memcached是什么,有什么作用? Memcached是一个开源的.高性能的内存缓存软件,从名称上看Mem就是内存的意思,而Cache就是缓存的意思. Memcached通过在事先规划好的内存空间 ...

  7. [ python ] 查询数据库生成Excel并发送邮件

    开发要求: 由于管理后台导出数据非常缓慢,找程序员解决无果后,自己动手写了一个脚本,每天定时将报表发送给业务部门. 1. 通过条件查询MySQL获取数据       2. 将获取的数据写入到Excel ...

  8. vue 组件中数据传递

    //有种形式的传递:从父到子,从子到父,平行级别的传递//首先第一种:从父到子,用props属性绑定 //父级数据: new vue({ "el":"#app" ...

  9. 去掉a标签的虚线框,避免出现奇怪的选中区域

    a{blr:expression(this.onFocus=this.blur())}/*去掉a标签的虚线框,避免出现奇怪的选中区域*/

  10. 基于UDP套接字编程实例

    data.h #ifndef DATA_H #define DATA_H #include <stdio.h> #include <string.h> #include < ...