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的更多相关文章

  1. C. Tourist Problem

    http://codeforces.com/problemset/problem/340/C 赛时没想出赛后却能较快想出深深的教育自己做题一定要静下心来,不要轻易放弃,认真思考,不要浮躁着急,不要太容 ...

  2. codeforces 340C Tourist Problem(公式题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Tourist Problem Iahub is a big fan of tou ...

  3. 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 ...

  4. 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 ...

  5. CodeForces - 340 C - Tourist Problem

    先上题目: A - Tourist Problem Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  6. C. Tourist Problem 2021.3.29 晚vj拉题 cf 1600 纯数学题

    拉题链接  https://vjudge.net/contest/430219#overview 原题链接  https://codeforces.com/problemset/problem/340 ...

  7. codeforces 340C Tourist Problem

    link:http://codeforces.com/problemset/problem/340/C 开始一点也没思路,赛后看别人写的代码那么短,可是不知道怎么推出来的啊! 后来明白了. 首先考虑第 ...

  8. CF 291E. Tree-String Problem [dfs kmp trie图优化]

    CF291E 题意:一棵树,每条边上有一些字符,求目标串出现了多少次 直接求目标串的fail然后一边dfs一边跑kmp 然后就被特殊数据卡到\(O(n^2)\)了... 因为这样kmp复杂度分析的基础 ...

  9. CF 732F Tourist Reform——v-SCC+dfs

    题目:http://codeforces.com/contest/732/problem/F 给无向图定向使得从每个点出发能去的点数最小值最大. SCC.点内部dfs定向.点间以siz最大的为起点反向 ...

随机推荐

  1. #ifdef __cplusplus extern "C" {代码} 倒底是什么意思?

    时常在cpp的代码之中看到这样的代码: #ifdef __cplusplus   extern "C" { #endif //一段代码 #ifdef __cplusplus } # ...

  2. 黑马程序员_Java面向对象_内部类

    6.面向对象_内部类 1.内部类定义 内部类:将一个类定义在另一个类里面,对里面那个类就称为内部类.(内置类.嵌套类)内部类可以被私有修饰. 2.内部类访问规则 访问特点: 内部类可以直接访问外部类中 ...

  3. C++基础回顾1(数据类型, 控制语句, 数组)

    最近两天打开本科学校的C++教材,快速回顾了一下C++方面的内容.虽然书本内容比较基础,但是还是有些知识点值得自己强化记忆.分几篇文章,加上自己的理解记录如下. 先回顾面向过程的部分. C++数据类型 ...

  4. One手动玩转

    <preface p2 by Ruiy,我就在开头简单奇葩两句!> 老周被查,涉及到政治问题,我先就不聊了,但Ruiy叹那,都查到七*务了,土党唱哪一出! 能基本玩转OpenNebula都 ...

  5. Window的匿名Closing 事件

    group.Closing += (sender, e) => { try {   Code here } } catch (Exception ex) { Exception here } } ...

  6. java DI 框架spring(web)、Guice(web)、Dagger&Dagger2(android)

    java DI 框架spring(web).Guice(web).Dagger&Dagger2(android) (待续...)

  7. 基于css制作轮播图的部分效果

    在轮播图中,我们可以通过鼠标在特定位置上的滑动来实现元素背景的改变.通常在制作轮播图时,我们首先想到的是js中的交互.可是,如果我们无法使用js,只能单纯的靠css又该如何实现这一效果呢?下面,本人将 ...

  8. Android SDK及ADT更新访问问题的解决办法

    一.访问问题Eclipse使用SDK Manager更新时总是出现问题 Failed to fetch URL https://dl-ssl.google.com/android/repository ...

  9. [CSS] :not Selector

    The CSS :not() selector allows us to exclude a subset of elements matched by our selector. In this e ...

  10. Android 通知栏用法例子

    当程序意外退出时,可以去掉通知栏上显示的图标 1.创建TestNotificationActivity activity类, package com.notioni.test.notification ...