https://abc093.contest.atcoder.jp/tasks/arc094_a?lang=en

思路题还是不太会做哈。感觉数据不大,一开始dfs做但是发现不是最优解,一想确实是这么一回事,然后转bfs,但是测第三组数据的时候就能看出来超时了。

其实这题仔细想想,只有两种情况最小值+2,一是大、中值相等时,如果最小值+2可以达到全部相等,或者比另两个大1然后另两个各+1;二是大值比小值大超过1,最后会达到一所说的局面。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<queue>
#define IO ios::sync_with_stdio(false);cin.tie(0);
const int MOD=1e9+;
typedef long long ll;
using namespace std;
int a[], cnt=;
int main()
{
for(int i = ; i < ; i++){
cin >> a[i];
}
sort(a, a+);
while(a[] != a[]){
cnt++;
if(a[] == a[] || a[]-a[]>)
a[] += ;
else a[]++, a[]++;
sort(a, a+);
}
cout << cnt << endl;
return ;
}

Atcoder4105 Same Integers(模拟)的更多相关文章

  1. Codeforces Educational Codeforces Round 5 A. Comparing Two Long Integers 高精度比大小,模拟

    A. Comparing Two Long Integers 题目连接: http://www.codeforces.com/contest/616/problem/A Description You ...

  2. [LeetCode] 数学计算模拟类问题:加法,除法和幂,注意越界问题。题 剑指Offer,Pow(x, n) ,Divide Two Integers

    引言 数学计算的模拟类题目,往往是要求实现某种计算(比如两数相除),实现的过程中会有所限定,比如不允许乘法等等. 这类题目首先要注意计算过程中本身的特殊情况.比如求相除,则必须首先反映过来除数不能为0 ...

  3. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  4. Codeforces Round #379 (Div. 2) A B C D 水 二分 模拟

    A. Anton and Danik time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  5. Codeforces Round #284 (Div. 2)A B C 模拟 数学

    A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...

  6. coderforces #387 Servers(模拟)

    Servers time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...

  7. Codeforces 740A. Alyona and copybooks 模拟

    A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: st ...

  8. Codeforces 738D. Sea Battle 模拟

    D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard inp ...

  9. [ACM_模拟] POJ1068 Parencodings (两种括号编码转化 规律 模拟)

    Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two diff ...

随机推荐

  1. alpha冲刺3/10

    目录 摘要 团队部分 个人部分 摘要 队名:小白吃 组长博客:hjj 作业博客:冲刺3 团队部分 后敬甲(组长) 过去两天完成了哪些任务 文字描述 组织第一次团队编程 继续阅读小程序开发文档 接下来的 ...

  2. js获取背景颜色

    //js获取背景颜色var Airport=$("#Airport").css('background-color'); js设置背景颜色 $("#intercity&q ...

  3. JavaSE| 泛型

    泛型 泛型:对后续所有操作的类型做约束,对后续操作起作用,对之前的不起作用: 对类型进行约束:  父 ----> 子,从范围上,父范围小,子范围大:把范围小的给范围大的, JDK1.5改写了集合 ...

  4. 基本标签-html-1

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. 了解fastadmin标准的控制器模块js的表格事件

    controller/A.php<-------------->public/assets/js/backend/a.js controller/b/A.php<---------- ...

  6. fastAdmin进阶

    基本知识流程一栏链接 bootstrapTable fastadmin系统配置(符内置规则): fastadmin默认的controller已实现的方法 一张图解析fastadmin的表格: fast ...

  7. react-antd 按需加载报错

    基于create-react-app 搭建的 react 项目 引入  antd UI  配置按需加载 但是报一下错误 .翻译过了一下 是内嵌JavaScript选项没有开启什么的 大白话就是 les ...

  8. 函数模拟sort快排

    设计一个对一维数组进行排序的sort函数,并调用它实现数组排序 思路:函数调用不止调用一个,最主要对函数不熟悉: #include<stdio.h> #define N 10 int ma ...

  9. C. A Mist of Florescence ----- Codeforces Round #487 (Div. 2)

    C. A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes input stan ...

  10. Pedestrian Attributes Recognition Paper List

    Pedestrian Attributes Recognition Paper List  2018-12-22 22:08:55 [Note] you may also check the upda ...