cf C. Tourist Problem
http://codeforces.com/contest/340/problem/C
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 100010
#define ll __int64
using namespace std; ll a[maxn];
int n; ll gcd(ll a,ll b)
{
return b==?a:gcd(b,a%b);
} int main()
{
scanf("%d",&n);
ll ans=;
for(int i=; i<n; i++)
{
scanf("%I64d",&a[i]);
ans+=a[i];
}
sort(a,a+n);
for(int i=; i<=n-; i++)
{
ans+=(a[i]-a[i-])*i*(n-i)*;
}
int k=gcd(ans,n);
printf("%I64d %I64d\n",ans/k,(ll)n/k);
return ;
}
cf C. Tourist Problem的更多相关文章
- C. Tourist Problem
http://codeforces.com/problemset/problem/340/C 赛时没想出赛后却能较快想出深深的教育自己做题一定要静下心来,不要轻易放弃,认真思考,不要浮躁着急,不要太容 ...
- codeforces 340C Tourist Problem(公式题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Tourist Problem Iahub is a big fan of tou ...
- Codeforces Round #198 (Div. 2) C. Tourist Problem
C. Tourist Problem time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #198 (Div. 2) C. Tourist Problem (数学+dp)
C. Tourist Problem time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- CodeForces - 340 C - Tourist Problem
先上题目: A - Tourist Problem Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- C. Tourist Problem 2021.3.29 晚vj拉题 cf 1600 纯数学题
拉题链接 https://vjudge.net/contest/430219#overview 原题链接 https://codeforces.com/problemset/problem/340 ...
- codeforces 340C Tourist Problem
link:http://codeforces.com/problemset/problem/340/C 开始一点也没思路,赛后看别人写的代码那么短,可是不知道怎么推出来的啊! 后来明白了. 首先考虑第 ...
- CF 291E. Tree-String Problem [dfs kmp trie图优化]
CF291E 题意:一棵树,每条边上有一些字符,求目标串出现了多少次 直接求目标串的fail然后一边dfs一边跑kmp 然后就被特殊数据卡到\(O(n^2)\)了... 因为这样kmp复杂度分析的基础 ...
- CF 732F Tourist Reform——v-SCC+dfs
题目:http://codeforces.com/contest/732/problem/F 给无向图定向使得从每个点出发能去的点数最小值最大. SCC.点内部dfs定向.点间以siz最大的为起点反向 ...
随机推荐
- Eclipse中安装TestNG插件
在Eclipse中安装TestNG也像安装其他插件一样非常方便,如下: 选择菜单:Help->Install New Software,然后在弹出窗口中的“Work with”中输入地址: ht ...
- Android ExpandableListActivity的简单介绍及小例子
Android中常常要用到ListView,但也经常要用到ExpandableListView,ListView是显示列表,而ExpandableListView显示的是分类的列表: 下面用一个例子来 ...
- bzoj4005[JLOI2015]骗我呢
http://www.lydsy.com/JudgeOnline/problem.php?id=4005 神题~远距离orz 膜拜PoPoQQQ大神 #include<cstdio> #i ...
- java开发经验分享(二)
二. 数据库 1. SQL语句中保留字.函数名要大写,表明.字段名全部小写 如:SELECT vc_name,vc_sex,i_age FROM user WHERE i_id = 100 AND i ...
- FROM CSDN TO CNBLOGS
做出了一个愉快的决定,以后会将博客从CSDN迁移到CNBLOGS 旧地址:http://blog.csdn.net/fifa0329,文章并不多 原因如下: 我再次出现了该博客违反了网站规则被关闭的问 ...
- PHP常用魔术方法(__toString魔术方法)
<?php //文件名:index.php define('a',__DIR__); include '/IMooc/Loader.php'; spl_autoload_register('\\ ...
- 【转】打包AAC码流到FLV文件
AAC编码后数据打包到FLV很简单.1. FLV音频Tag格式 字节位置 意义0x08, ...
- openfire文件夹
插件开发 学习制作第一个 openfire 插件 http://www.cnblogs.com/jying/p/3683409.html 跟我一步一步开发自己的Openfire插件 http://bl ...
- Sass函数--map
MapSass 的 map 常常被称为数据地图,也有人称其为数组,是以 key:value 成对的出现. $map: ( $key1: value1, $key2: value2, $key3: va ...
- css布局详解(一)——盒模型
一.网页布局的几种情况 今天让我们总结一下在css布局的各种情况做一个总结,为我们以后布局网页时做一个参考. 先看一张图,这是去年cssConf大会时阿里的 @寒冬winter 老师放出来的: 如图所 ...