codeforces 633A A. Ebony and Ivory(暴力)
2 seconds
256 megabytes
standard input
standard output
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.
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.
Print "Yes" (without quotes) if Dante can deal exactly c damage to the shield and "No" (without quotes) otherwise.
4 6 15
No
3 2 7
Yes
6 11 6
Yes
In the second sample, Dante can fire 1 bullet from Ebony and 2 from Ivory to deal exactly 1·3 + 2·2 = 7 damage. In the third sample, Dante can fire 1 bullet from ebony and no bullets from ivory to do 1·6 + 0·11 = 6 damage.
题意很简单,直接暴力;
AC代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
for(int i=0;i< c/a+2;i++)
{
for(int j=0;j<c/b+2;j++)
{
if(i*a+j*b==c)
{
cout<<"YES";
return 0;
}
}
}
cout<<"NO";
return 0;
}
codeforces 633A A. Ebony and Ivory(暴力)的更多相关文章
- codeforces Ebony and Ivory(水题)
A. Ebony and Ivory time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Manthan, Codefest 16 A. Ebony and Ivory 水题
A. Ebony and Ivory 题目连接: http://www.codeforces.com/contest/633/problem/A Description Dante is engage ...
- Manthan, Codefest 16 -A Ebony and Ivory
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- Codeforces Gym 100513M M. Variable Shadowing 暴力
M. Variable Shadowing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/ ...
- Codeforces Gym 100513G G. FacePalm Accounting 暴力
G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513 ...
- Codeforces Gym 100002 C "Cricket Field" 暴力
"Cricket Field" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1000 ...
- Codeforces 839A Arya and Bran【暴力】
A. Arya and Bran time limit per test:1 second memory limit per test:256 megabytes input:standard inp ...
- Codeforces 827E Rusty String - 快速傅里叶变换 - 暴力
Grigory loves strings. Recently he found a metal strip on a loft. The strip had length n and consist ...
- Codeforces Beta Round #3 B. Lorry 暴力 二分
B. Lorry 题目连接: http://www.codeforces.com/contest/3/problem/B Description A group of tourists is goin ...
随机推荐
- HDU 5045 5047 5050 5053(上海网络赛E,F,I,L)
HDU 5045 5047 5050 5053 太菜了,名额差点没保住.吓尿..赶紧开刷树链抛分 5045:状压DP.压缩10个人.因为两个人不能差2以上,所以能够用01表示 5047:推推公式就可以 ...
- Laravel开发:多用户登录验证(1)
之前实现了一次,后来代码忘记放哪了,所以有跳了一次坑. 先贴上Laravel自带的验证代码: 路由:routes/web.php // Authentication Routes... $this-& ...
- 笔试真题解析 ALBB-2015 算法project师实习生机试
1.用十进制计算30!(30的阶乘),将结果转换成3进制进行表示的话,该进制下的结果末尾会有____个0. [解析] 计算N.下3进制结果末尾有多少个0,事实上就是计算3进制中的3被进位多少次,仅仅要 ...
- Catalan数以及使用Raney引理证明
一.Catalan数性质 1.1 令h(0)=1,h(1)=1,catalan数满足递推式: h(n)= h(0)*h(n-1)+h(1)*h(n-2) + ... + h(n-1)h(0) ...
- Sumdiv(较难数学题)
Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20971 Accepted: 5290 Description Cons ...
- Hadoop DataNode 节点的动态添加和动态删除
动态添加 DataNode 节点 hadoop环境是必须的 需要加入新的 DataNode 节点,前提是已经配置好 SSH 无密登录:直接复制已有DataNode中.ssh目录中的authorized ...
- visual studio2017 无法添加引用 未能加载包ReferenceManagerPackage not such interface support 解决方法
安装完visual studio 2017 后添加引用总是提示 未能加载包ReferenceManagerPackage, 这个问题困扰了两天,直到在网上看到了下面这一段 I just got thi ...
- ASP-AJAX-分页格式
HTML: <html> <head> <title>Mazey</title> <meta name="description&quo ...
- cocos2d-x CCControl控件
感谢点评与关注.欢迎转载与分享.勤奋努力,持之以恒! CCControlSlider 滑动条 void HelloWorld::myInit10() { CCSize size = CCDirecto ...
- LeetCode:删除排序链表中的重复元素【83】
LeetCode:删除排序链表中的重复元素[83] 题目描述 给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次. 示例 1: 输入: 1->1->2 输出: 1->2 示 ...