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. Win7下Qt5的安装及使用

    1.安装Qt5 Qt5的安装比Qt4的安装简单多了,我装的是Qt5.4(qt-opensource-windows-x86-mingw491_opengl-5.4.0.exe),它集成了MinGW.Q ...

  2. MySQL用户及权限管理

    查看用户 mysql>SELECT user, host FROM mysql.user; # 检索mysql数据库中的user表 % 表示所有主机的IP 查看当前用户 mysql> se ...

  3. tomcat 、eclipse插件安装、一个机器安装多个tomcat、tomcat闪退的问题解决

    一.正常情况下 (1)新建三个系统变量:tomcat的安装路径 TOMCAT_HOME=E:\tomcat-6.0.39 CATALINA_HOME=E:\tomcat-6.0.39 CATALINA ...

  4. 【转】Linq表达式、Lambda表达式你更喜欢哪个?

    [转]Linq表达式.Lambda表达式你更喜欢哪个? 什么是Linq表达式?什么是Lambda表达式? 如图: 由此可见Linq表达式和Lambda表达式并没有什么可比性. 那与Lambda表达式相 ...

  5. 【Go】 Go 语言环境安装

    安装环境/工具 1.Linux(CentOS 7.4版) 2.go1.11.2.linux-amd64.tar Go 语言环境安装 1.下载安装包 安装包下载地址为:https://golang.or ...

  6. Servlet 知识点 中文乱码的本质与解决

    本质原因:在servlet中出现中文乱码的原因编码和解码采用的不是一个编码表或者两个编码表不是兼容 例如UTF-8编码.GBK编码都可以读取中文,那么如果采用UTF-8编码保存文件,但是采用GBK编码 ...

  7. ManageEngine卓豪 IT管理峰会圆满结束

  8. LSTM长短期记忆神经网络模型简介

    LSTM网络也是一种时间递归神经网络,解决RNN的长期依赖关系. RNN模型在训练时会遇到梯度消失或者爆炸的问题,训练时计算和反向传播,梯度倾向于在每一时刻递增或递减,梯度发散到无穷大或者0..... ...

  9. IDEA的GUI连接数据库写入SQL语句的问题总结

    一.首先是建立游标的对象statement 插入数据excuteUpdate需要的是一个整型的参数,所以建立的对象要是一个int型的数据类型,才可以执行SQL语句excuteQuery是一个字符类型在 ...

  10. jquery中ajax处理跨域的三大方式

    一.处理跨域的方式: 1.代理 2.XHR2 HTML5中提供的XMLHTTPREQUEST Level2(及XHR2)已经实现了跨域访问.但ie10以下不支持 只需要在服务端填上响应头: ? 1 2 ...