swustoj(0541)
来源:互联网 发布:淘宝怎么改追加评价 编辑:程序博客网 时间:2024/05/09 00:46
#include<stdio.h>#include<iostream>#include<algorithm>#include<stack>using namespace std;int jiecheng(int x){int ans = 1;for (int i = 1; i <= x; i++){ans *= i;}return ans;}int a[20];void fun(){a[0] = 1;for (int i = 1; i <= 15; i++){a[i] = jiecheng(i);}}int main(){int n;while (cin >> n){int tt = n;int num[20];fun();for (int i = 0; i < n; i++){cin >> num[i];}int ans = 0;for (int i = 0; i < n; i++){int cnt = 0;for (int j = i + 1; j < n; j++){if (num[j] < num[i]){cnt++;}}ans += a[--tt] * cnt;}cout << ans << endl;next_permutation(num, num + n);//下一个字典序for (int i = 0; i < n; i++){cout << num[i] << ' ';}cout << endl;}return 0;}
0 0
- swustoj(0541)
- swustOJ哈弗曼编码(985)
- swustoj(0303取模)
- swustoj-1212(凑硬币)
- swustoj大整数乘法(0447)
- swustoj-Buyer(0195)(01背包)
- swustoj-A interesting game(0194)(博弈)
- swustoj(Escape(1023))(多状态BFS)
- swustoj----249凸包的面积(分治法)
- swustoj求最小生成树(Prim算法)(1075)
- swustoj-0249(凸包面积)(计算几何)
- swustoj---1091
- swustoj(667)
- swustoj(统计在简单选择排序中的数据交换的次数(1109))
- swustoj---254翻煎饼
- swustoj----142猴子报数
- swustoj---700Delete Numbers
- 翻煎饼 swustoj 254
- 制作安卓系统
- 解决Eclipse闪退问题的几种方案总结
- 关于ButterKnife 8.4.0以后版本报空指针的使用注意事项:
- selenium之 定位以及切换frame(iframe)
- 【WEB】Sass与Compass安装与入门(二)
- swustoj(0541)
- 五bean之间的继承与依赖
- mybatis分表策略shard
- QFileDialog::getOpenFileName
- mybatis中使用in查询时的注意事项
- Android网络框架选择(Volley、OkHttp、Retrofit)
- 人生中第一次做面试官的经历与总结
- 如何上传本地文件到Github
- 校园导航系统