Manthan, Codefest 16 -A Ebony and Ivory
| time limit per test | 2 seconds |
|---|---|
| memory limit per test | 256 megabytes |
| input standard | input |
| output 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.
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.
Examples
input
4 6 15
output
No
input
3 2 7
output
Yes
input
6 11 6
output
Yes
Note
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.
题意:判断c 能不能由A,B组成
暴力枚举即可
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const double PI = acos(-1.0);
int a,b,c;
int main()
{
cin>>a>>b>>c;
bool flag=false;
for(int i=0;a*i<=c;i++)
{
if((c-a*i)%b==0)
{
flag= true;
break;
}
}
if(flag)
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
return 0;
}
Manthan, Codefest 16 -A Ebony and Ivory的更多相关文章
- 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 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 ...
随机推荐
- Static方法在多线程环境下的运行
最近看了Jfinal 一致对model的那个static final dao有些疑惑,全局一个实例安全吗?同时也出了一个疑惑,静态方法执行会有并发影响吗?看代码 StaticThread.java p ...
- css补充、JavaScript、Dom
css补充: position: fixed:可以将标签固定在页面的某个位置 absolute+relative:通过两者的结合可以让标签在一个相对的位置 代码例子:(通过fixed标签将某些内容固定 ...
- Java c3p0连接池之二
<?xml version="1.0" encoding="UTF-8"?> <!-- c3p0-config.xml文件配置 --> ...
- delphi 判断一个数组的长度用 Length 还是 SizeOf ?
判断一个数组的长度用 Length 还是 SizeOf ?最近发现一些代码, 甚至有一些专家代码, 在遍历数组时所用的数组长度竟然是 SizeOf(arr); 这不合适! 如果是一维数组.且元素大小是 ...
- Leetcode: Minimum Unique Word Abbreviation
A string such as "word" contains the following abbreviations: ["word", "1or ...
- SP2-0618: 无法找到会话标识符。启用检查 PLUSTRACE 角色 SP2-0611: 启用 STATISTICS 报告时出错
援引: SP2-0618: 无法找到会话标识符.启用检查 PLUSTRACE 角色 SP2-0611: 启用 STATISTICS 报告时出错 问题描述及解决方法: SQL*Plus: Release ...
- PHP中GPC
PS:PHP中绕过GPC的情况有很多,本文仅仅是总结了一些比较常见的,而且写的很浅[因为本人水平有限],欢迎大家积极拍砖:) 1.通过数据库(文本)中转 通过数据库中转: [注意存入数据库和selec ...
- 显示textarea内容的时候没有自动换行
显示textarea内容的时候没有自动换行,网上找了好久,在一个论坛里找到解决方法: 1.把从数据库读出来的内容存放在一个Div内,例如: <div class="new-commen ...
- REq,RES编码设置
import java.io.IOException; import javax.servlet.Filter;import javax.servlet.FilterChain;import java ...
- UVALive 7148 LRIP(树的分治+STL)(2014 Asia Shanghai Regional Contest)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...