codeforces 686B
题意:给出一个序列,只允许进行相邻的两两交换,给出使序列变为非降序列的操作方案。
思路:关键点是操作次数不限,冒泡排序。
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
ll num[];
int main() {
int n;
while(~scanf("%d",&n)) {
for(int i=;i<n;i++) {
cin>>num[i];
}
int temp;
for(int i=;i<n;i++) {
for(int j=;j<n-;j++) {
if(num[j]>num[j+]) {
temp=num[j+];
num[j+]=num[j];
num[j]=temp;
cout<<j+<<" "<<j+<<endl;
}
}
}
} return ;
}
codeforces 686B的更多相关文章
- CodeForces 686B Little Robber Girl's Zoo (构造冒泡排序)
题意:给定一排列,让你通过一个区间交换的方式,完成排序. 析:这个题说了,最多不能超过20000次,而 n 最大才100,那么冒泡排序复杂度为 n * n,才10000,肯定是可以的,所以我们就模拟冒 ...
- codeforces 686B B. Little Robber Girl's Zoo(水题)
题目链接: B. Little Robber Girl's Zoo //#include <bits/stdc++.h> #include <vector> #include ...
- Codeforces Round #359 div2
Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
随机推荐
- About the Apple Captive Network Assistant
If you’re a mac user, you likely have seen a strange popup window appear on your computer when you t ...
- 解决Windows平台通过cURL上传APP到蒲公英pgyer平台时无法使用中文升级描述的问题
解决Windows平台通过cURL上传APP到蒲公英pgyer平台时无法使用中文升级描述的问题 官方上传命令 curl -F file=@"315.apk" -F uKey=XXX ...
- C++中没有定义类的引用。
在有时候由于类太大.须要在类在后面定义: 比如: class Y{ void f(X); }; class X{ //一些成员数据和函数 }; //error 由于c++要求不论什么一个变量在引用之前 ...
- 常见Linux/Unix开发辅助命令什锦
很多零碎命令集锦: 1. 怎样通过命令下载ftp文件 read -s -p "Your passwd: " Passwd; wget --user=YourUserName --p ...
- ThinkPHP3.1URL分发BUG修正
请先留意以下PHP脚本 PHP脚本A(http://127.0.0.1:8110/test.php): $url = 'http://127.0.0.1:8110/demo.php'; //curl请 ...
- org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: Unknown column 'viewpoint' in 'field list'
问题描述:当我在model中添加了一下代码以后数据库报错: 添加的代码为: private Viewpoint viewpoint; public Viewpoint getViewpoint() { ...
- Eclipse中Copy Qualified Name复制类全名解决办法
Eclipse中用Copy Qualified Name复制类全名时总是这样的/struts1/src/me/edu/HelloAction.java很不方便可以这样解决下载下边插件解压到Eclips ...
- iOS - 每隔一段时间,反复执行同一个任务
我们有时候会有这样的需求,当程序处于运行状态,每隔几秒给服务器发送一次请求. 这时我们可以这样处理: UILocalNotification *localNotification = [[UILoca ...
- python 上传文件下载图片
python 2.7 poster-0.8.1 requests-2.7.0 #coding:utf-8import urllibimport urllib2import sysimport time ...
- 使用UIImageView展现来自网络的图片
本文转载至 http://www.cnblogs.com/chivas/archive/2012/05/21/2512324.html UIImageView:可以通过UIImage加载图片赋给UII ...