XDOJ1256-1118-1116
来源:互联网 发布:纯种狗是退化知乎 编辑:程序博客网 时间:2024/06/06 17:25
接下来读入case组数据,每组第一行为2个整数n(1<=n<=20),k(1<=k<=n)。
接下来一行共n个一位小数(大于0小于1),表示这n个学生来上课的概率
3 1
0.1 0.1 0.1
#include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>using namespace std;double dp[25][25];double ans=0;int a,b,c,d,e,f,t;double p[25];int n,k;int main(){ cin>>t; while (t--) { ans=0; memset(dp,0,sizeof(dp)); cin>>n>>k; for (a=1;a<=n;a++) cin>>p[a]; dp[0][0]=1; for (a=0;a<n;a++) for (b=0;b<=a;b++) if (dp[a][b]!=0) { dp[a+1][b]+=dp[a][b]*(1-p[a+1]); dp[a+1][b+1]+=dp[a][b]*p[a+1]; } double temp=0; for (a=0;a<k;a++) temp+=dp[n][a]; temp=1-temp; ans=temp/(1-temp); printf("%.1lf\n",ans); } return 0;}
1118 - XDUgirls
There are many pretty girls in Xidian University, and as we know, every girl loves pretty clothes, so do they. One day some of them got a huge rectangular cloth and they want to cut it into small rectangular pieces to make scarves. But different girls like different style, and they voted each style a price wrote down on a list. They have a machine which can cut one cloth into exactly two smaller rectangular pieces horizontally or vertically, and ask you to use this machine to cut the original huge cloth into pieces appeared in the list. Girls wish to get the highest profit from the small pieces after cutting, so you need to find out a best cutting strategy. You are free to make as many scarves of a given style as you wish, or none if desired. Of course, the girls do not require you to use all the cloth.
The first line of each case consists of three integers N, X, Y, N indicating there are N kinds of rectangular that you can cut in and made to scarves; X, Y indicating the dimension of the original cloth. The next N lines, each line consists of two integers, xi, yi, ci, indicating the dimension and the price of the ith rectangular piece cloth you can cut in.
Constrains
0 < T <= 20
0 <= N <= 10; 0 < X, Y <= 1000
0 < xi <= X; 0 < yi <= Y; 0 <= ci <= 1000
2 4 4
2 2 2
3 3 9
#include<iostream>#include<string.h>using namespace std;int a,b,c,d,e,f;int t,n,x,y,arr[1050][1050];int xi[15],yi[15],ci[15];int main(){ cin>>t; while (t--) { int best=0; memset(arr,0,sizeof(arr)); cin>>n>>x>>y; for (a=1;a<=n;a++) cin>>xi[a]>>yi[a]>>ci[a]; for (a=0;a<=x;a++) for (b=0;b<=y;b++) for (int i=1;i<=n;i++) { if (xi[i]<=a && yi[i]<=b) { arr[a][b]=max(arr[a][b],arr[a][b-yi[i]]+arr[a-xi[i]][yi[i]]+ci[i]); arr[a][b]=max(arr[a][b],arr[a-xi[i]][b]+arr[xi[i]][b-yi[i]]+ci[i]); } if (yi[i]<=a && xi[i]<=b) { arr[a][b]=max(arr[a][b],arr[a][b-xi[i]]+arr[a-yi[i]][xi[i]]+ci[i]); arr[a][b]=max(arr[a][b],arr[a-yi[i]][b]+arr[yi[i]][b-xi[i]]+ci[i]); } } cout<<arr[x][y]<<endl; } return 0;}
The American English slash (/) is a punctuation mark. In the early modern period, in the Fraktur script, which was widespread through Europe in the Middle Ages, one slash(/) represented a comma, while two slashes (//) represented a dash.
With the wide use of computers, slash appeared far more than at any previous time in history. On Unix-like systems and in URLs, the slash is to separate directory and file components of a path:
/home/whuacm/chaeyeon/Sherlockpp.jpg
http://acm.whu.edu.cn/
But in Windows systems, it uses (\) to separate directory and file components of a path:
C:\Users\v-yungao\Music\Shake
That really confuses me. Could you help me to judge if the string I wrote is right.
Please notice that I would only make a mistake by changing (\) to (/) or (/) to (\). All the strings were constituted by a-z, A-Z, 0-9, (.) , (\) and (/), no other characters would appear in the strings.
A string of URL always begins with “[a-zA-Z]+://” (Notice (/) maybe changed to (\) ), in which “[a-zA-Z]+” represents any non-empty string of letters.
Windows path begins with “[a-zA-Z]:\” (Notice (\) maybe changed to (/)), in which “[a-zA-Z]” means an English letter. (e.g. “C:\\windows” is a URL not a Windows path)
The path of Unix-like system begins with (/) or (\).
I’ll give you some strings, can you tell me which type those strings belong to and those correct forms.
The next T lines, each line consists of a single non-empty string. All of those are really data from our daily life.
If it belongs to a path in Unix-like systems, output “It’s a path in Unix-like systems!” in a new line and the correct string in the next line.
If it belongs to a path in Windows system, output “It’s a path in Windows system!” in a new line and the correct string in the next line.
If it’s a URL, output “It’s a URL!” in a new line and the correct string in the next line.
The kind of each input string can be uniquely determined.
Constrains
0 < T <= 20
The length of each string will not be longer than 50.
http://acm.whu.edu.cn/felioj
http:/\acm.whu.edu.cn/11111011001/
\home\whuacm\Slash\yama
Z:\movie/chaeyeon
http://acm.whu.edu.cn/felioj
It's a URL!
http://acm.whu.edu.cn/11111011001/
It's a path in Unix-like systems!
/home/whuacm/Slash/yama
It's a path in Windows system!
Z:\movie\chaeyeon
#include<iostream>#include<string.h>using namespace std;int a,b,c,d,e,f;int t;string s;char fuck;int main(){ fuck='\\'; cin>>t; while (t--) { cin>>s; if (s[0]=='/' || s[0]==fuck) { for (a=0;a<s.size();a++) if (s[a]==fuck) s[a]='/'; cout<<"It's a path in Unix-like systems!"<<endl; cout<<s<<endl; continue; } int temp=0; while (s[temp]!=':') temp++; if (s[temp+2]=='/' || s[temp+2]==fuck) { cout<<"It's a URL!"<<endl; for (a=0;a<s.size();a++) if (s[a]==fuck) s[a]='/'; cout<<s<<endl; continue; } if (s[temp+1]=='/' || s[temp+1]==fuck) { cout<<"It's a path in Windows system!"<<endl; for (a=0;a<s.size();a++) if (s[a]=='/') s[a]=fuck; cout<<s<<endl; continue; } }}
- XDOJ1256-1118-1116
- JOJ 1115 1116 1117 1118
- 1116
- POJ 1118
- 1118a
- POJ 1118
- poj 1118
- poj 1118
- URAL 1118
- PKU 1118
- ZOJ-1118
- poj 1118
- POJ-1118
- poj 1118
- 1118 -- 调和级数
- PAT 1118
- HDU 1116
- hdu 1116
- oracle创建数据库后创建自己的用户
- T4替换空格
- 个人网站tuzkiss.net更新(一)
- 从过程到对象
- 设置flex应用程序加载完毕后自动获取到输入焦点
- XDOJ1256-1118-1116
- lucms表结构
- Cocos2dx 响应Android返回键和Menu键
- Eclipse配置PyDev插件
- Recover Binary Search Tree 恢复发生错误的BST (重重重)!!!(参考别人的)
- 程序奔溃原因
- 快乐飞深刻的航空公司的开了个上课了冠军联赛看见了开始
- UIViewController的生命周期
- WebRTC in the real world: STUN, TURN and signaling