【2019沈阳网络赛】G、Special necklace——自闭的物理题
这道题让我差点怀疑自己高考没考过物理
题意中
he measures the resistance of any two endpoints of it, the resistance values are all 2a2a2a
指的是在三角形中电阻为 2a2a2a 而不是边上的电阻为 2a2a2a
实际上每条边的电阻R为
1R+12R=2a\frac{1}{R} + \frac{1}{2R} = 2aR1+2R1=2a
可以求得R=3aR = 3aR=3a
所以可以得到递推公式
an+1=1111an+43+3+13a_{n+1} = \frac{1}{ \frac{1}{ \frac{1}{ \frac{1}{a_{n}} + \frac{4}{3}} + 3} + \frac{1}{3}}an+1=an1+341+31+311
通过python打表
res = 5 / 3
print('%.20f' % res)
for i in range(20):
res = 1 / ((1 / (1 / (1 / res + 4 / 3) + 3)) + 1 / 3)
print('%.20f' % res)
得到
1.66666666666666674068
1.61904761904761906877
1.61805555555555535818
1.61803444782168193150
1.61803399852180329610
1.61803398895790206957
1.61803398875432269399
1.61803398874998927148
1.61803398874989712297
1.61803398874989490253
1.61803398874989468048
1.61803398874989468048
1.61803398874989468048
1.61803398874989468048
1.61803398874989468048
1.61803398874989468048
1.61803398874989468048
1.61803398874989468048
1.61803398874989468048
1.61803398874989468048
1.61803398874989468048
这是 a=1a = 1a=1 的情况,最后乘上 a 就行
很明显了,直接打表就行,借助一下字符串流
#include <bits/stdc++.h>
using namespace std;
vector<double> res;
void init() {
res.push_back(1.66666666666666674068);
res.push_back(1.61904761904761906877);
res.push_back(1.61805555555555535818);
res.push_back(1.61803444782168193150);
res.push_back(1.61803399852180329610);
res.push_back(1.61803398895790206957);
res.push_back(1.61803398875432269399);
res.push_back(1.61803398874998927148);
res.push_back(1.61803398874989712297);
res.push_back(1.61803398874989468048);
res.push_back(1.61803398874989468048);
res.push_back(1.61803398874989468048);
res.push_back(1.61803398874989468048);
res.push_back(1.61803398874989468048);
res.push_back(1.61803398874989468048);
}
void solve() {
int t;
cin >> t;
init();
while (t--) {
string str;
double a;
cin >> str >> a;
if (str.length() > 2) {
cout << fixed << setprecision(10) << res.back() * a << endl;
continue;
}
stringstream ss(str);
int n;
ss >> n;
if (n > res.size() - 1) {
cout << fixed << setprecision(10) << res.back() * a << endl;
} else {
cout << fixed << setprecision(10) << res[n - 1] * a << endl;
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifdef ACM_LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
long long test_index_for_debug = 1;
char acm_local_for_debug;
while (cin >> acm_local_for_debug) {
cin.putback(acm_local_for_debug);
if (test_index_for_debug > 20) {
throw runtime_error("Check the stdin!!!");
}
auto start_clock_for_debug = clock();
solve();
auto end_clock_for_debug = clock();
cout << "Test " << test_index_for_debug << " successful" << endl;
cerr << "Test " << test_index_for_debug++ << " Run Time: "
<< double(end_clock_for_debug - start_clock_for_debug) / CLOCKS_PER_SEC << "s" << endl;
cout << "--------------------------------------------------" << endl;
}
#else
solve();
#endif
return 0;
}
【2019沈阳网络赛】G、Special necklace——自闭的物理题的更多相关文章
- 2019南昌网络赛G. tsy's number
题意:\(\sum_{i=1}^n\sum_{j=1}^n\sum_{k=1}^n\frac{\phi(i)*\phi(j^2)*\phi(k^3)}{\phi(i)*\phi(j)*\phi(k)} ...
- 2019 沈阳网络赛 Fish eating fruit
这题看了三个月,终于过了,第一次看的时候没学树形DP,想用点分治但是不会 后来学了二次扫描,就有点想法了.... 这东西也真就玄学了吧... #include<iostream> #inc ...
- 2019沈阳网络赛B.Dudu's maze
https://www.cnblogs.com/31415926535x/p/11520088.html 啊,,不在状态啊,,自闭一下午,,都错题,,然后背锅,,,明明这个简单的题,,, 这题题面不容 ...
- [2019沈阳网络赛D题]Dawn-K's water(点分治)
题目链接 题意为求出树上任意点对的距离对3取余的和. 比赛上听到题意就知道是点分治了,但是越写越不对劲,交之前就觉得会T,果不其然T了.修修改改结果队友写了发dp直接就过了Orz. 赛后想了想维护的东 ...
- 2019 徐州网络赛 G Colorful String 回文树
题目链接:https://nanti.jisuanke.com/t/41389 The value of a string sss is equal to the number of differen ...
- 2019 沈阳网络赛 D Fish eating fruit ( 树形DP)
题目传送门 题意:求一颗树中所有点对(a,b)的路径长度,路径长度按照模3之后的值进行分类,最后分别求每一类的和 分析:树形DP \(dp[i][j]\) 表示以 i 为根的子树中,所有子节点到 i ...
- 2019沈阳网赛树形dp
https://nanti.jisuanke.com/t/41403 2019沈阳网络赛D题 树形dp.一棵树,求任意两个点的距离之和.u-v和v-u算两次.两点之间的距离分为三类,模3等于0,1,2 ...
- 2018 ICPC 沈阳网络赛
2018 ICPC 沈阳网络赛 Call of Accepted 题目描述:求一个算式的最大值与最小值. solution 按普通算式计算方法做,只不过要同时记住最大值和最小值而已. Convex H ...
- ICPC 2019 徐州网络赛
ICPC 2019 徐州网络赛 比赛时间:2019.9.7 比赛链接:The Preliminary Contest for ICPC Asia Xuzhou 2019 赛后的经验总结 // 比赛完才 ...
随机推荐
- 那些让程序员目瞪口呆的Bug
程序员一生与bug奋战,可谓是杀敌无数,见怪不怪了!在某知识社交平台中,一个"有哪些让程序员目瞪口呆的bug"的话题引来了6700多万的阅读,可见程序员们对一个话题的敏感度有多高. ...
- 初识Spring JdbcTemplate
JdbcTemplate 概述 JdbcTemplate是Spring提供的一个模板类,它是对jdbc的封装.用于支持持久层的操作.具有简单,方便等特点. pom.xml <!--依赖版本--& ...
- 【桌面篇】Archlinux安装kde桌面
ArchLinux安装配置手册[桌面篇] 现在你的U盘可以拔掉了,重启后会发现和刚刚没什么区别,还是命令行的界面,别着急现在就带你安装桌面环境. 连接网络 首先检查一下网络是否连接成功 ping ww ...
- Mac开发环境部署
1. 安装 Xcode command line tools xcode-select --install 2. 安装 Homebrew 安装 Homebrew 之前,必须先安装 Xcode Comm ...
- win10 64位 安装JDK1.8
win10 64位 jdk1.8 配置Java环境,是否安装JRE. 一.安装得有JRE JDK和JRE分别安装再不同的文件夹下 新建:JAVA_HOME 值:JDK的安装路径 新建:CLASSPAT ...
- Enbale IE mode in Edge
1. 打开Edge, 在地址栏输入 edge://flags/ 2. 搜索 Enable IE Integration , 配置为 IE mode 3. 找到Edge的启动程序路径.如 C:\Prog ...
- 前端开发: webStorm手机真机调试
目录 1. 做好准备工作 2. 开始设置 3. 配置路径 4. 匹配路径设置 5. 设置完成,即可体验 文章首发微信公众号飙码人生 2018-05-21 18:21:15 1. 做好准备工作 安装we ...
- 一起了解 .Net Foundation 项目 No.16
.Net 基金会中包含有很多优秀的项目,今天就和笔者一起了解一下其中的一些优秀作品吧. 中文介绍 中文介绍内容翻译自英文介绍,主要采用意译.如与原文存在出入,请以原文为准. Orchard CMS O ...
- git删除远程仓库中的文件夹
具体操作如下: git rm -r --cached .history #删除目录 git commit -m”删除.history文件夹” git push -r表示递归所有子目录,如果你要删 ...
- php -v 找不到命令
[root@localhost htdocs]# php -v -bash: php: command not found export PATH=$PATH:/usr/local/php7/bin ...