这道题让我差点怀疑自己高考没考过物理

题意中

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​=an​1​+34​1​+31​+31​1​

通过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——自闭的物理题的更多相关文章

  1. 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)} ...

  2. 2019 沈阳网络赛 Fish eating fruit

    这题看了三个月,终于过了,第一次看的时候没学树形DP,想用点分治但是不会 后来学了二次扫描,就有点想法了.... 这东西也真就玄学了吧... #include<iostream> #inc ...

  3. 2019沈阳网络赛B.Dudu's maze

    https://www.cnblogs.com/31415926535x/p/11520088.html 啊,,不在状态啊,,自闭一下午,,都错题,,然后背锅,,,明明这个简单的题,,, 这题题面不容 ...

  4. [2019沈阳网络赛D题]Dawn-K's water(点分治)

    题目链接 题意为求出树上任意点对的距离对3取余的和. 比赛上听到题意就知道是点分治了,但是越写越不对劲,交之前就觉得会T,果不其然T了.修修改改结果队友写了发dp直接就过了Orz. 赛后想了想维护的东 ...

  5. 2019 徐州网络赛 G Colorful String 回文树

    题目链接:https://nanti.jisuanke.com/t/41389 The value of a string sss is equal to the number of differen ...

  6. 2019 沈阳网络赛 D Fish eating fruit ( 树形DP)

    题目传送门 题意:求一颗树中所有点对(a,b)的路径长度,路径长度按照模3之后的值进行分类,最后分别求每一类的和 分析:树形DP \(dp[i][j]\) 表示以 i 为根的子树中,所有子节点到 i ...

  7. 2019沈阳网赛树形dp

    https://nanti.jisuanke.com/t/41403 2019沈阳网络赛D题 树形dp.一棵树,求任意两个点的距离之和.u-v和v-u算两次.两点之间的距离分为三类,模3等于0,1,2 ...

  8. 2018 ICPC 沈阳网络赛

    2018 ICPC 沈阳网络赛 Call of Accepted 题目描述:求一个算式的最大值与最小值. solution 按普通算式计算方法做,只不过要同时记住最大值和最小值而已. Convex H ...

  9. ICPC 2019 徐州网络赛

    ICPC 2019 徐州网络赛 比赛时间:2019.9.7 比赛链接:The Preliminary Contest for ICPC Asia Xuzhou 2019 赛后的经验总结 // 比赛完才 ...

随机推荐

  1. 第12章 Reference-RIL运行框架

    Reference-RIL完成两部分处理逻辑: 与LibRIL交互完成RIL消息的处理. 与Modem通信模块交互完成AT命令的执行. Reference-RIL的运行机制 主要涉及以下几个方面: R ...

  2. 如何进行Web服务的性能测试

         涉及到web服务的功能在不断的增加,对于我们测试来说,我们不仅要保证服务端功能的正确性,也要验证服务端程序的性能是否符合要求.那么性能测试都要做些什么呢?我们该怎样进行性能测试呢? 性能测试 ...

  3. kafka&&kafka-manager部署安装

    一.zk集群部署 二.kafka部署安装 1.创建kafka用户和日志路径,(直接执行) groupadd kafka useradd -g kafka kafka mkdir -p /web/kaf ...

  4. Soulwail

    XMLHttpRequest 属性解读 首先在 Chrome console 下创建一个 XMLHttpRequest 实例对象 xhr.如下所示: inherit 试运行一下代码. var xhr ...

  5. RxJava 2.x 源码分析

    本次分析的 RxJava 版本信息如下: 12 implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'implementation 'io.reac ...

  6. 在虚拟机单机部署OpenStack Grizzly

    安装过程 安装Ubuntu 我手头有的是Ubuntu Server 12.04 64位版,就直接用了,默认安装即可,配置的时候很简单,如下 内存:1G 硬盘:20G 处理器:2 网络:NAT 装好以后 ...

  7. Flask设置Access-Control_Allow_Origin实现跨域访问

    前端访问Flask的接口,浏览器报错:has been blocked by CORS policy: No 'Access-Control-Allow-Origin' heade 需要将Flask的 ...

  8. spring——AOP原理及源码(一)

    教程共分为五篇,从AOP实例的构建及其重要组件.基本运行流程.容器创建流程.关键方法调用.原理总结归纳等几个方面一步步走进AOP的世界. 本篇主要为读者演示构建AOP实例及AOP核心组件分析. 一.项 ...

  9. Manjaro 19.01 kde下Tim sogou软件安装问题及解决

    我的系统配置 首先第一个问题是,在manjaro下Tim Thunderspeed这种deepin-wine的软件.今天我在装这些软件的时候,安装之后不能打开,闪退.苦恼了我好一会儿.终于找到了解决的 ...

  10. Eureka 注册中心看这一篇就够了

    服务注册中心是服务实现服务化管理的核心组件,类似于目录服务的作用,主要用来存储服务信息,譬如提供者 url 串.路由信息等.服务注册中心是微服务架构中最基础的设施之一. 在微服务架构流行之前,注册中心 ...