简单题。

第一次交换$1$和$n$,第二次交换$2$和$n-1$,第三次交换$3$和$n-2$.....计算一下就可以了。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c=getchar(); x=;
while(!isdigit(c)) c=getchar();
while(isdigit(c)) {x=x*+c-''; c=getchar();}
} int n,k; int main()
{
scanf("%d%d",&n,&k);
if(k>n/) k=n/;
LL ans=; int num=n;
for(int i=;i<=k;i++)
{
ans=ans+num-+num-;
num=num-;
}
printf("%lld\n",ans);
return ;
}

CodeForces 645B Mischievous Mess Makers的更多相关文章

  1. Codeforces 645B Mischievous Mess Makers【逆序数】

    题目链接: http://codeforces.com/problemset/problem/645/B 题意: 给定步数和排列,每步可以交换两个数,问最后逆序数最多是多少对? 分析: 看例子就能看出 ...

  2. Code Forces 645B Mischievous Mess Makers

    It is a balmy spring afternoon, and Farmer John's n cows are ruminating about link-cut cacti in thei ...

  3. codeforces 655B B. Mischievous Mess Makers(贪心)

    题目链接: B. Mischievous Mess Makers time limit per test 1 second memory limit per test 256 megabytes in ...

  4. CROC 2016 - Elimination Round (Rated Unofficial Edition) B. Mischievous Mess Makers 贪心

    B. Mischievous Mess Makers 题目连接: http://www.codeforces.com/contest/655/problem/B Description It is a ...

  5. codeforces 655C C. Enduring Exodus(二分)

    题目链接: C. Enduring Exodus time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  6. codeforces645B

    Mischievous Mess Makers CodeForces - 645B It is a balmy spring afternoon, and Farmer John's n cows a ...

  7. CROC 2016 - Elimination Round (Rated Unofficial Edition) C. Enduring Exodus 二分

    C. Enduring Exodus 题目连接: http://www.codeforces.com/contest/655/problem/C Description In an attempt t ...

  8. Code Forces 645C Enduring Exodus

    C. Enduring Exodus time limit per test2 seconds memory limit per test256 megabytes inputstandard inp ...

  9. CodeForces - 645F:Cowslip Collections (组合数&&欧拉函数)

    In an attempt to make peace with the Mischievious Mess Makers, Bessie and Farmer John are planning t ...

随机推荐

  1. 如何用CSC.exe来编译Visual C#的代码文件

    原文:如何用CSC.exe来编译Visual C#的代码文件 C#的编译过程      如何用CSC.exe来编译Visual C#的代码文件   Csc.exe 编译器的位置路径:C:\Window ...

  2. Inno Setup connection to the database and create

    原文 Inno Setup connection to the database and create Description: the first half of this program in I ...

  3. javascript 学习总结(六)RegExp对象

    1.正则表达式test方法 var text = "cat, bat, sat, fat"; var pattern = /.at/; if (pattern.test(text) ...

  4. 微软BI 之SSIS 系列 - 使用 Script Task 访问非 Windows 验证下的 SMTP 服务器发送邮件

    原文:微软BI 之SSIS 系列 - 使用 Script Task 访问非 Windows 验证下的 SMTP 服务器发送邮件 开篇介绍 大多数情况下我们的 SSIS 包都会配置在 SQL Agent ...

  5. NHibernate 数据查询之QueryOver<T>

    NHibernate 数据查询之QueryOver<T>   一.限制运算符 Where:筛选序列中的项目WhereNot:反筛选序列中的项目 二.投影运算符 Select:创建部分序列的 ...

  6. ASP.Net中应用百度编辑器(UEditor)上传图片和上传附件失败-解决方案

    第一步: 第二步: 第三步: 第四步:

  7. C#单元测试工具包:MvcContrib

    C#单元测试工具包:MvcContrib http://t.cn/hE67d https://mvccontrib.codeplex.com/documentation MVC Contrib Doc ...

  8. 用户故事(User Story)

    用户故事(User Story)       用户故事是描述对用户有价值的功能,好的用户故事应该包括角色.功能和商业价值三个要素.用户故事通常的格式为:作为一个<角色>, 我想要<功 ...

  9. .NET里的行为驱动开发

    BDD (Given - When - then) Ruby Cucumber, Java FitNesse , Python RoboFramework, C# specflow nspec .NE ...

  10. CentOS6.8安装mysql5.6

    一.下载mysql5.6 下载地址,并上传至Linux 二.查看CentOS是否自带的mysql rpm -qa | grep mysql 三.卸载自带的mysql rpm -e --nodeps m ...