Password Hacking CSU 1966
来源:互联网 发布:js 多功能日历插件 编辑:程序博客网 时间:2024/05/01 02:14
Description
We all know that passwords are not very secure unless users are disciplined enough to use passwords that are difficult to guess. But most users are not so careful, and happily use passwords such as “123456”. In fact, there are lists of commonly used passwords that hackers can use for breaking into systems, and these passwords often work.
You have done a lot of hacking using such lists, and you have a good idea of how likely each password in the list is the correct one (you are very surprised by the number of people using “123456” as their passwords). You have a new account to hack, and you have decided to try each of the passwords in the list one at a time, until the correct one is found. You are absolutely sure that the account you want to hack uses a password in the given list.
What is the expected number of attempts to find the correct passwords, assuming that you try these passwords in the optimal order?
Input
The first line of input contains a positive integer N, the number of passwords in the list. Each of the next N lines gives the password, followed by a space, followed by the probability that the password is the correct one. Each password is a non-empty string consisting only of alphanumeric characters and is up to 12 characters long. Each probability is a real number with 4 decimal places. You may assume that there are at most 500 passwords in the list, and that the sum of all probabilities equals 1. No two passwords in the list are the same.
Output
Output on a single line the expected number of attempts to find the correct passwords using the optimal order. Answers within 10−4 of the correct answer will be accepted.
Sample Input
2123456 0.6666qwerty 0.33343qwerty 0.5432123456 0.3334password 0.1234
Sample Output
1.33341.5802
Hint
Source
2017湖南多校第十三场
水题,不解释。
代码如下:
/* Author:kzl */#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>#include<string>using namespace std;char ch[20];double cun[550];int n;int main(){while(scanf("%d",&n)!=EOF){ for(int i=0;i<n;i++){ scanf("%s",ch);scanf("%lf",&cun[i]); } double sum = 0; sort(cun,cun+n); for(int i=n-1;i>=0;i--){ sum += cun[i] * (n-i);}printf("%.4lf\n",sum);}return 0;}
- Password Hacking CSU 1966
- Password Hacking AIO Options
- Password Hacking -34in1
- Website Password hacking using WireShark
- hacking
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- java初级开发面试题全集(下)
- 剑指Offer----二叉树的镜像
- IDEA配置github并上传项目
- 机器学习实战python版决策树以及Matplotlib注解绘制决策树
- JSP--第十三天
- Password Hacking CSU 1966
- tail
- MFC消息简介
- 倒计时 js
- Case Studio 2连接数据库反向生成schema
- spring cloud 使用feign 遇到问题
- java枚举常量的使用
- C语言中矩阵定义问题(续)
- 每天一个linux命令(25):文件权限命令 chgrp命令