http://codeforces.com/problemset/problem/135/A

题意 : 我能说我卡在这个题的题意上很久吗。。。。。这个题就是在数组里找一个数,然后找另一个数把他替换掉,然后再对数组进行排序,输出可能的数组最小值。。。。

思路 : 一开始没反应过来,不知道要替换掉哪个数,后来一想才明白,要求最后得到的最小,那就把最大的那个替换掉不就行了,而且最简单的还是替换成1,然后要注意的一点是因为题目中说必须要替换掉一个,而且不能用自己替换掉自己,所以要考虑万一输入的全是1,就要替换成2。。。。

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std ;
int a[] ;
int main()
{
int n ;
while(cin >> n)
{
for(int i = ; i < n ; i++)
scanf("%d",&a[i]) ;
sort(a,a+n) ;
if(a[n-] == )
a[n-] = ;
else{a[n-] = ;
sort(a,a+n) ;
}
sort(a,a+n) ;
for(int i = ; i < n- ; i++)
printf("%d ",a[i]) ;
printf("%d\n",a[n-]) ;
}
return ;
}

CF135A Replacement的更多相关文章

  1. CF135A Replacement 题解

    Content 有 \(n\) 个数 \(a_1,a_2,a_3,...,a_n\),试用 \(1\) ~ \(10^9\) 之间的数(除了本身)代替其中的一个数,使得这 \(n\) 个数的总和最小, ...

  2. BeautifulSoup Some characters could not be decoded, and were replaced with REPLACEMENT CHARACTER.

    BeautifulSoup很赞的东西 最近出现一个问题:Python 3.3 soup=BeautifulSoup(urllib.request.urlopen(url_path),"htm ...

  3. LeetCode 397. Integer Replacement

    397. Integer Replacement QuestionEditorial Solution My Submissions   Total Accepted: 5878 Total Subm ...

  4. NuGet在创建pack时提示”The replacement token 'author' has no value“问题解决

    在创建pack时出现了“The replacement token 'author' has no value”的错误提示. 解决方法: 1.可能程序没生成过,在解决方案上重新生成解决方案,注意Deb ...

  5. 加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Section 2 Random sampling with and without replacement

    Stat2.2x Probability(概率)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  6. Codeforces Codeforces Round #316 (Div. 2) C. Replacement set

    C. Replacement Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/proble ...

  7. Is C# a clone of a Microsoft replacement for Java?

    Is C# a clone of a Microsoft replacement for Java?Let's look at what Anders Hejlsberg Said. Hejlsber ...

  8. Codeforces Codeforces Round #316 (Div. 2) C. Replacement 线段树

    C. ReplacementTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/problem ...

  9. [转]Using Replacement Strings with Regex.Replace

    本文转自:http://www.knowdotnet.com/articles/regereplacementstrings.html The String.Replace function has ...

随机推荐

  1. C盘空间不足,释放C盘空间

    最近电脑总是特别卡,后来发现C盘空间严重不足,只剩下几十兆,以前最严重的时候是剩下0kb可以,怎一个惨字了得... 我所知道的C盘空间不足会导致的几个主要问题有: 1)拷贝大文件会失败.因为拷贝和剪切 ...

  2. 第五篇、Uber用视频播放做启动动画

    import UIKit import AVFoundation class GuidePage: FxBasePage { @IBOutlet var backImageView:UIImageVi ...

  3. WCF学习笔记 -- 基本概念

    WCF是实现WebService的一种微软提出的技术,整合了.Remote, .NET及ASP.NET服务的一种框架.是Windows Communication Foundation的缩写.WebS ...

  4. c# 远程回收IIS应用池

    利用下列代码可实现IIS应用池的远程回收 var serverManager = ServerManager.OpenRemote(ip); var appPools = serverManager. ...

  5. 常用DOM笔记

    1,获取元素方法: (1),获取单个,返回一个元素 element.getElementById()//最快,实时 element.querySelector() (2)获取多个,返回一组 eleme ...

  6. 指针与strncpy---内存

    指针的形式的赋值和strncpy的赋值 e.SetAttr("Amt", ToString(dAmt)      ); e.SetAttr("Amt", sAm ...

  7. ES6学习笔记(二)

    1.数组的解构赋值 基本用法 ES6允许按照一定模式,从数组和对象中提取值,对变量进行赋值,这被称为解构(Destructuring). 以前,为变量赋值,只能直接指定值. var a = 1; va ...

  8. Linux进程间通信IPC学习笔记之同步二(Posix 信号量)

    Linux进程间通信IPC学习笔记之同步二(Posix 信号量)

  9. 跨域解决方案CORS使用方法

    CORS(Cross-Origin Resource Sharing), 目前CORS还处于w3c的草案,它定义了跨域访问时服务器和客户端之间如何通信.他的原理是通过定义HTTP头部的信息,来让客户端 ...

  10. CentOS 6.5 安装与配置LAMP

    准备工作: 1.配置防火墙,开启80端口.3306端口vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --d ...