[acm]HDOJ 3082 Simplify The Circuit

题目地址:

http://acm.hdu.edu.cn/showproblem.php?pid=3082



字符串处理+并联电阻公式

 1 //11481261    2014-08-18 16:52:47    Accepted    3082    0MS    384K    733 B    G++    空信高手
 2 #include<string>
 3 #include<iostream>
 4 #include<cstdio>
 5 #include<cstdlib>
 6
 7 using namespace std;
 8
 9 int main()
10 {
11     //freopen("input.txt","r",stdin);
12     string str;
13     int Sum=0,nCases=0,count=0;
14     cin>>count;
15     double circuit=0;
16     while(count--)
17     {
18         cin>>nCases;
19         circuit=0;
20         while(nCases--)
21         {
22             cin>>str;
23             Sum=0;
24             int end = 0;
25             int pre = 0;
26             while(end<str.length())
27             {
28                 if(str[end]==‘-‘)
29                     end++;
30                 else
31                 {
32                     pre=end;
33                     while((str[end]!=‘-‘)&&(end<str.length()))
34                     {
35                         end++;
36                     }
37                     //字符串分割
38                     string str1 = str.substr(pre,end-pre);
39                     int i = atoi(str1.c_str());
40                     Sum+=i;
41                 }
42             }
43             circuit+=1.0/Sum;  //并联电阻公式
44         }
45         printf("%.2lf\n",1.0/circuit);
46     }
47
48     return 0;
49 }

[acm]HDOJ 3082 Simplify The Circuit

时间: 2024-11-05 20:48:07

[acm]HDOJ 3082 Simplify The Circuit的相关文章

[acm]HDOJ 2064 汉诺塔III

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2064 汉诺塔变种,只能从中间专业,递归关系为:f(n)=3*f(n-1)+2. 1 //汉诺塔变种,只能从中间转移 2 //11485816 2014-08-19 08:44:47 Accepted 2064 0MS 368K 307 B G++ 空信高手 3 #include<iostream> 4 #include<cstdio> 5 using namespace std; 6

[acm]HDOJ 2059 龟兔赛跑

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2059 起点和终点,共n+2个点,n+2个状态,简单DP即可. 1 //11512698 2014-08-21 17:11:55 Accepted 2059 2 //62MS 368K 969 B G++ 空信高手 3 //起点和终点,共n+2个点,n+2个状态,简单DP即可 4 #include<iostream> 5 #include<cstdio> 6 using namespa

[acm]HDOJ 1200 To and Fro

题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1200 简单字符串处理,找规律 1 /* 2 11509672 2014-08-21 11:32:55 Accepted 3 1200 0MS 380K 442 B G++ 空信高手 4 */ 5 #include<iostream> 6 #include<string> 7 #include<cstdio> 8 using namespace std; 9 int mai

[acm]HDOJ 2673 shǎ崽 OrOrOrOrz

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2673 拍两次序,交替输出 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 using namespace std; 5 #define MAX_NUMBER 10000 6 bool myfunction1 (int i,int j) { return (i<j); } 7 bool m

acm hdoj 1157

Who's in the Middle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3136 Accepted Submission(s): 1171   Problem Description FJ is surveying his herd to find the most average cow. He wants to know

Simple dc/dc converter increases available power in dual-voltage system

The schematic in Figure 1 shows a way to increase the power available from a current-limited 5V supply by adding power from a –5V supply. The dc/dc converter generates a single 12V, 150-mA (1.8W) output from two regulated and current-limited input so

HDOJ ACM题目分类

模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 120

2016 ACM/ICPC Asia Regional Qingdao Online1001 &amp;&amp;hdoj 5878 I Count Two Three

题目链接 打表二分..后来发现这是51nod中的一个原题 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 using namespace std; 5 typedef long long int ll; 6 const ll INF = 1e9 + 100000; 7 ll a[100005]; 8 int cnt = 0; 9 int x[] = {2,3,5, 7}; 10 voi

HDOJ 3547 DIY Cube 解题报告

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3547 题目大意:求用$C$种颜色给立方体的8个顶点染色的本质不同的方法.两种方法本质不同即不能通过旋转立方体使得两个立方体的染色情况一致. 简要题解:首先可以得到有24种组合旋转方式.根据Polya定理以及群论中的拉格朗日定理,然后再自己多想一想,就可以得到:$Ans=\frac{x^8+Ax^4+Bx^2+Cx}{24}$,可知有3个未知数,然后样例正好有3组数据,所以可以解方程解得$A=17,B