codeforces 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.
题意:给你a b c三个数,问是否存在x y使得a*x+b*y=c
数据不大直接暴力求解
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define DD double
#define MAX 100100
#define mod 10007
#define dian 1.000000011
using namespace std;
int main()
{
int a,b,c,t,n,m,i,j;
while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
int flag=0;
for(i=0;i<=c/a;i++)
{
if((c-i*a)%b==0)
{
flag=1;
break;
}
}
if(flag) printf("Yes\n");
else printf("No\n");
}
return 0;
}
codeforces 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 ...
- Codeforces Gym 100531G Grave 水题
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...
- codeforces 706A A. Beru-taxi(水题)
题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...
- codeforces 569B B. Inventory(水题)
题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces 489A SwapSort (水题)
A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- codeforces 688A A. Opponents(水题)
题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- CodeForces 534B Covered Path (水题)
题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...
- Codeforces Gym 100286I iSharp 水题
Problem I. iSharpTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- CodeForces 705A(训练水题)
题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it ...
随机推荐
- Android开发之获取系统版本号
获取系统版本号:获取当前系统的版本号: textView.setText("Product Model: " + android.os.Build.MODEL + ",& ...
- 2014年百度之星程序设计大赛 - 资格赛 1004 Labyrinth(Dp)
题目链接 题目: Labyrinth Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- poj 1703 Find them, Catch them(并查集)
题目:http://poj.org/problem?id=1703 题意:一个地方有两个帮派, 每个罪犯只属于其中一个帮派,D 后输入的是两个人属于不同的帮派, A后询问 两个人是否属于 同一个帮派. ...
- Android开发学习笔记:浅谈GridView
GridView(网格视图)是按照行列的方式来显示内容的,一般用于显示图片,图片等内容,比如实现九宫格图,用GridView是首选,也是最简单的.主要用于设置Adapter. GridView常用的X ...
- WebClient+Fiddler2完美搭配下载远程页面信息
WebClient可以下载远程页面信息,这个大家应该都知道,核心代码如下: WebClient web = new WebClient(); string url = String.Format(&q ...
- 利用改进的cca算法,进行识别
这个方法,很有意思,第一,不用降维:第二,跟ica做比较,竟然说比强大的ica还好: 看来,国防科大的博士,还是很牛的. <OI and fMRI Signal Separation Using ...
- 04day1
无穷的数列 找规律 [问题描述] 有一个无穷序列如下: 110100100010000100000- 请你找出这个无穷序列中指定位置上的数字. [输入] 第一行一个正整数 N,表示询问次数:接下来的 ...
- 《C++ Primer 4th》读书笔记 第3章-标准库类型
原创文章,转载请注明出处:http://www.cnblogs.com/DayByDay/p/3911534.html
- win下Velocity安装和试用
1.eclipse等就不说了 2.velocity的eclipse插件: http://www.oschina.net/p/veloeclipse(介绍) 方法1(现在基本上非常慢)http://pr ...
- Delphi richedit获取选中文字
function TForm1.GetSendText(RichEdit: TExRichEdit): string;var MsgListInfo: TStrings; i, m, n: i ...