URAL 2066 Simple Expression (水题,暴力)

题意:给定三个数,让你放上+-*三种符号,使得他们的值最小。

析:没什么好说的,全算一下就好。肯定用不到加,因为是非负数。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define frer freopen("in.txt", "r", stdin)
#define frew freopen("out.txt", "w", stdout)
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 8;
const int mod = 1e9 + 7;
const char *mark = "+-*";
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
    return r >= 0 && r < n && c >= 0 && c < m;
}

int main(){
    int a, b, c;
    while(scanf("%d %d %d", &a, &b, &c) == 3){
        int ans = a - b * c;
        ans = Min(ans, b - a * c);
        ans = Min(ans, c - a * b);
        ans = Min(ans, a - b - c);
        ans = Min(ans, b - a - c);
        ans = Min(ans, c - b - a);
        printf("%d\n", ans);
    }
    return 0;
}

  

  

时间: 2024-10-23 12:09:00

URAL 2066 Simple Expression (水题,暴力)的相关文章

[2016-04-16][URAL][2066][Simple Expression]

时间:2016-04-16 20:04:26 星期六 题目编号:[2016-04-16][URAL][2066][Simple Expression] 题目大意:给出 a b c三个数字,在他们之间插入 + - *,问能得到的最小值是多少? 分析:直接枚举- #include<cstdio> #include<algorithm> using namespace std; int main(){ int a,b,c; scanf("%d%d%d",&a,

HDU ACM 5224 Tom and paper 水题+暴力枚举

分析:因为长和宽都是整数,所以枚举判断是不是整数,再取最小的即可. #include<iostream> #include<cmath> using namespace std; int main() { int min; int a,i,T; ios::sync_with_stdio(false); cin>>T; while(T--) { cin>>a; min=1000000000; for(i=1;i<=sqrt(a);i++) if(a%i=

URAL 1023 Buttons(巴什博弈水题)

1023. Buttons Time limit: 2.0 secondMemory limit: 64 MB Background As you surely already know, Yekaterinburg has gotten its right to hold The Summer Olympic Games of the 2032. It is planned that it will be allowed to Russia as a country-organizer to

[Usaco2008 Feb]Line连线游戏[暴力][水题]

Description Farmer John最近发明了一个游戏,来考验自命不凡的贝茜.游戏开始的时 候,FJ会给贝茜一块画着N (2 <= N <= 200)个不重合的点的木板,其中第i个点 的横.纵坐标分别为X_i和Y_i (-1,000 <= X_i <=1,000: -1,000 <= Y_i <= 1,000). 贝茜可以选两个点画一条过它们的直线,当且仅当平面上不存在与画出直线 平行的直线.游戏结束时贝茜的得分,就是她画出的直线的总条数.为了在游戏 中胜出,

URAL 1039 Anniversary Party 树形DP 水题

1039. Anniversary Party Time limit: 0.5 secondMemory limit: 8 MB Background The president of the Ural State University is going to make an 80'th Anniversary party. The university has a hierarchical structure of employees; that is, the supervisor rela

HDU 4143 A Simple Problem(数论-水题)

A Simple Problem Problem Description For a given positive integer n, please find the smallest positive integer x that we can find an integer y such that y^2 = n +x^2. Input The first line is an integer T, which is the the number of cases. Then T line

CodeForces 589I Lottery (暴力,水题)

题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cma

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive

涨姿势题2_水题_两种解法

Problem Description 涨姿势题就是所谓的优化题,在组队赛中,队伍发现了一题水题,那么应该交给谁去处理?作为处理水题的代码手,应该具备什么样的素养?1,要快,水题拼的就是速度!2,不能卡水题!水题都卡,绝对不是一个代码手的风范!3,不能出错,错一次即罚时20分钟,对于水题来讲是致命的!4,要能看出来一题是水题!没有这条,上面三条都是没有意义的! 如果你希望你成团队中一个合格的代码手,那么这套题是你最好的选择,快AC吧! 本系列即是为了提高水题代码手的素养而准备的!水题经常需要用到