Manthan, Codefest 16 A. Ebony and Ivory 水题
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 水题的更多相关文章
- Manthan, Codefest 16 -A Ebony and Ivory
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- Manthan, Codefest 16
暴力 A - Ebony and Ivory import java.util.*; import java.io.*; public class Main { public static void ...
- Manthan, Codefest 16 D. Fibonacci-ish
D. Fibonacci-ish time limit per test 3 seconds memory limit per test 512 megabytes input standard in ...
- 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 ...
- Manthan, Codefest 16 -C. Spy Syndrome 2
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- CF Manthan, Codefest 16 G. Yash And Trees 线段树+bitset
题目链接:http://codeforces.com/problemset/problem/633/G 大意是一棵树两种操作,第一种是某一节点子树所有值+v,第二种问子树中节点模m出现了多少种m以内的 ...
- CF #Manthan, Codefest 16 C. Spy Syndrome 2 Trie
题目链接:http://codeforces.com/problemset/problem/633/C 大意就是给个字典和一个字符串,求一个用字典中的单词恰好构成字符串的匹配. 比赛的时候是用AC自动 ...
- CF Manthan, Codefest 16 B. A Trivial Problem
数学技巧真有趣,看出规律就很简单了 wa 题意:给出数k 输出所有阶乘尾数有k个0的数 这题来来回回看了两三遍, 想的方法总觉得会T 后来想想 阶乘 emmm 1*2*3*4*5*6*7*8*9 ...
- Manthan, Codefest 16 H. Fibonacci-ish II 大力出奇迹 莫队 线段树 矩阵
H. Fibonacci-ish II 题目连接: http://codeforces.com/contest/633/problem/H Description Yash is finally ti ...
随机推荐
- 超级rtmp服务器和屌丝wowza
超级rtmp服务器和屌丝wowza http://blog.csdn.net/win_lin/article/details/11927973
- 【bzoj1068】【SCOI2007】压缩
一道区间dp f[i][j][0/1]表示[i,j]区间是否加入M,并且之前一位有M的最小长度 可以理解为在第一位之前有一个M 那么就可以转移了. #include<bits/stdc++.h& ...
- HDU 5136 Yue Fei's Battle
题目链接:HDU-5136 网上的一篇题解非常好,所以就直接转载了.转自oilover的博客 代码: #include<cstring> #include<cstdio> #i ...
- C后端设计开发 - 第5章-内功-数据结构下卷
正文 第5章-内功-数据结构下卷 后记 如果有错误, 欢迎指正. 有好的补充, 和疑问欢迎交流, 一块提高. 在此谢谢大家了.
- 解决springmvc+fastjson返回页面出现乱码问题
在controller里面的接口上面加,produces="text/html;charset=UTF-8"即可 @RequestMapping(value = "/ad ...
- php常见术语
什么是PHP? php是Hypertext Preprocessor的缩写,php是一种内嵌 HTML的脚本语言.PHP的独特语法混合了c,java和perl及PHP式的新语法.这门语言的的目标是让网 ...
- java字符串转换数值类型出现异常赋予默认值
http://blog.csdn.net/w47_csdn/article/details/77855126 可以自定义工具方法,例如: public static int parseInt(Stri ...
- Intellij idea的maven依赖图
Intellij idea下查看maven的依赖图与eclipse有所不同.下面简单介绍一下Intellij下maven的查看使用. 使用场景 当你想查看maven依赖的jar都有哪些,是否有冲突,冲 ...
- vue不用webpake等环境及脚手架也可以玩
初学时,搭环境,es6也来了,vuecil脚手架也弄了,调错,照着教程一遍一遍kei着... 然尔,实际开发中,所写的东西最后是要打包封装成软件的,为了方便其他人修改查看,不能打包成js文件... 难 ...
- Template Mode 'HTML5' is deprecated与UnsatisfiedDependencyException
org.thymeleaf.templatemode.TemplateMode : [THYMELEAF][main] Template Mode 'HTML5' is deprecated. Usi ...