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. bloomfilter 以及count min sketch

    bloomfilter http://blog.csdn.net/v_july_v/article/details/6685894 count min sketch http://www.cnblog ...

  2. c#不同数组之间的转换【转载,消化自动删除】

    c#中从string数组转换到int数组 string[] input = { "1", "2", "3", "4", ...

  3. HISAT2+StringTie+Ballgown安装及使用流程

    HISAT2+StringTie+Ballgown安装及使用流程 2015年Nature Methods上面发表了一款快速比对工具hisat,作为接替tophat和bowtie的比对工具,它具有更快的 ...

  4. Delphi中静态方法重载还是覆盖的讨论

    Delphi中静态方法重载还是覆盖的讨论 新人学习Delphi的时候,容易搞不懂的一个问题,当子类方法和基类方法同名,并且参数也一样的时候,叫做什么呢?是覆盖,还是重载呢? 答案是隐藏父类方法. 一般 ...

  5. JSP脚本元素(声明 %! 表达式 %= 脚本 %)

    JSP脚本元素包括声明.表达式.脚本 声明(declaration):用于在JSP页面中声明合法的变量和方法.以“<%!”开始,以“%>”结束. 在JSP页面中,一个声明可以出现在任何地方 ...

  6. 美食类Web原型制作分享-Taste

    Taste是国外知名的美食类网站,为人们提供丰富的美食菜单,帮助人们更好的享受美食带来的快乐.网站采用图文结合的排版方式,有固定顶部导航栏的交互功能等. 本原型由国产原型工具Mockplus和团队协作 ...

  7. Sliding Window Median LT480

    Median is the middle value in an ordered integer list. If the size of the list is even, there is no ...

  8. GRADLE下运行main函数/执行测试用例

    group 'gongsibao.ged' version '1.0-SNAPSHOT' apply plugin: 'java' apply plugin: 'idea' sourceCompati ...

  9. 实现SQL express版做自动备份数据库的方法

    SQL Server 2005/2008 Express版没有代理组件,不支持维护计划.可以采用下面的办法实现每日备份: 一.在要备份的数据库中创建存储过程. 存储过程名称:sp_BackupData ...

  10. 通过flask中的Response返回json数据

    使用flask的过程中,发现有时需要生成一个Response并返回.网上查了查,看了看源码,找到了两种办法: from flask import Response, json Response(jso ...