日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

国家集训队2009 书堆

發布時間:2023/11/27 生活经验 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 国家集训队2009 书堆 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

洛谷

BZOJ

分析

實際上就是求重心坐標。

假設第 \(i\) 本書的重心為 \(g_i\) ,不難發現:

\[\frac{g_2+g_3+...+g_n}{n-1}+g_1=0\]

\[\frac{g_2+g_3+...+g_n}{n-1}-g_1=M\]

于是有:

\[g_n=\frac{M}{2}\sum^{n}_{i=1}{\frac{1}{i}}\]

但此題還要用到調和計數這個東西,由于窩太菜了,所以自行百度。

代碼

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define il inline
#define re register
#define tie0 cin.tie(0),cout.tie(0)
#define fastio ios::sync_with_stdio(false)
#define File(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout)
using namespace std;
typedef long long ll;template <typename T> inline void read(T &x) {T f = 1; x = 0; char c;for (c = getchar(); !isdigit(c); c = getchar()) if (c == '-') f = -1;for ( ; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);x *= f;
}ll n, m;
double ans, eps = 1e-6;int main() {read(n), read(m);if (n <= 1e7)for (int i = 2; i <= n*2; i += 2) ans += 1.0/i;else ans += (log(n) + 0.5772156649) / 2;ans *= m; ans -= eps;printf("%d\n", (int)ans);return 0;
}

轉載于:https://www.cnblogs.com/hlw1/p/11437197.html

總結

以上是生活随笔為你收集整理的国家集训队2009 书堆的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。