250pt:

给出一个数n(n <= 10^10),问至少修改几位能使其变成完全平方数。

思路:
    直接枚举平方根,然后统计。
    注意枚举时要枚举到比她大。。
 #line 7 "LotteryCheating.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair #define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i) typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII; class LotteryCheating
{
public:
int bit[], L = ;
int work(long long x){
int ret = ;
for (int i = ; i < L + ; ++i){
if (x % != bit[i]) ++ret;
x /= ;
}
return ret;
}
int minimalChange(string ID)
{
int sz = ID.size();
L = sz;
memset(bit, , sizeof(bit));
long long n = ;
for (int i = ; i < sz; ++i)
n = n * + ID[i] - , bit[sz-i-] = ID[i] - ;
int ans = ;
for (long long i = ; i * i <= n * ; ++i)
ans = min(work(i * i), ans);
return ans; } };
500pt:
     彩票上有N行5列的格子,其中有1-5*N的排列。抽奖会抽出5个数来,如果彩票上一行有超过三个抽出的数则中奖。

问彩票中奖概率。
思路:
     直接枚举中奖的情形,那么有可能是3行 2行,1行。
     对于3行,只有可能是3+1+1,
     对于2行,4 + 1
     对于1行,5
    其他全排列即可
 #line 7 "LotteryPyaterochka.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair #define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i) typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII; class LotteryPyaterochka
{
public:
double C(int n, int m){
double ret = 1.0;
for (int i = ; i <= m; ++i)
ret *= (n - i + 1.0) / (i + .);
return ret;
}
double A(int n, int m){
double ret = 1.0;
for (int i = ; i <= m; ++i)
ret *= (n - i + 1.0);
return ret;
}
double chanceToWin(int N)
{
if (N <= ) return 1.0;
double ans = ;
ans += C(N, ) * C(N - , ) * C(, ) * C(, ) * C(, ) * A(, );
ans += C(N, ) * C(N - , ) * C(, ) * C(, ) * A(, );
ans += C(N, ) * C(N - , ) * C(, ) * C(, ) * A(, );
ans += C(N, ) * A(, );
cout << ans << endl;
for (int i = ; i < ; ++i)
ans /= ( * N - i + .);
return ans;
} };

SRM466的更多相关文章

随机推荐

  1. SD-WAN介绍

    SD-WAN SD-WAN特性 相关技术 Hybrid WAN WAN Optimization WAN edge router MPLS NFV SDN SD-WAN厂商 SD-WAN SD-WAN ...

  2. Delphi各种Socket组件的模式和模型

    Delphi各种Socket组件的模式和模型 Delphi的大多数书籍里面都没有提到delphi的各种socket通信组件的模式和模型,有的书只讲解了windows的socket模式和模型,并没有归纳 ...

  3. refused to Connection

    两种情况: .数据库账号密码错误 .mysql挂了

  4. Eclipse中配置Tomcat服务器并创建标准Web目录

    Eclipse创建 Java Web 项目,并生成标准的目录结构 file --> New --> Dynamic Web project 填写 Project name (该名称项目的名 ...

  5. Laravel Relationship Events

    Laravel Relationship Events is a package by Viacheslav Ostrovskiy that adds extra model relationship ...

  6. How to reconfigure installed dpkg package (tzdata, locales)

    1 List the installed dpkg package $ sudo dpkg --list 2 Reconfigure the package $ sudo dpkg-reconfigu ...

  7. 开学习实用的笔试面试技术:linux

    1.F:\Movies\尚学堂大数据周末班原版(传智大数据第三期):课程比较乱,按照顺序都学了吧 1.linux基础:原来不会linux就废了.一定要装虚拟机.2018-05-27开搞. 服务器只能装 ...

  8. java链表实现

    import java.util.Scanner; class DATA2 { String key; // 结点的关键字 String name; int age; } class CLType / ...

  9. 【搜索】Shuffle'm Up

    运用第i个s12和第i+1个s12中,每个位置具有的确定的映射关系: pos = pos * 2 + 1 (pos < c) pos = pos * 2 - c * 2 (pos >= c ...

  10. Mysql #1406 Data too long 错误

    Mysql #1406 Data too long 错误 http://blog.sina.com.cn/s/blog_68004f680100kgfh.html B. Mysql配置文件:   “在 ...