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. 796B Find The Bone

    B. Find The Bone time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  2. linux使用笔记4

    运行已经安装好的软件: cd到这个软件的安装目录 输入命令/:./软件名称 就可以了 运行geoserver 1.首先需要添加JAVA_HOME的环境变量: 在服务器没有设置JAVA_HOME的情况下 ...

  3. 多维数组sorted函数的用法

    对某一个位置排列 l=[[1,5,7,9],[5,10,6,11],[4,2,1,4]] newlist=sorted(l,key=lambda iterm : iterm[0],reverse=Tr ...

  4. Eclipse生成部署描述符(web.xml)

    右键点击你的web项目名--->Java EE Tools-->Generate Deployment  Descriptor Stub 要想自动生成,只需在创建web项目时,把最后一页的 ...

  5. Python之路(第十六篇)xml模块、datetime模块

    一.xml模块 xml是实现不同语言或程序之间进行数据交换的协议,跟json差不多,但json使用起来更简单, xml比较早,早期许多软件都是用xml,至今很多传统公司如金融行业的很多系统的接口还主要 ...

  6. Pairs of Songs With Total Durations Divisible by 60 LT1010

    In a list of songs, the i-th song has a duration of time[i] seconds. Return the number of pairs of s ...

  7. iOS11 适配

    参考:http://kisscu.com/2018/07/01/%E9%80%82%E9%85%8Dios-11%E6%80%BB%E7%BB%93/ self.navigationItem.righ ...

  8. 13个开源GIS软件 你了解几个?

    地理信息系统(Geographic Information System,GIS)软件依赖于覆盖整个地球的数据集.为处理大量的 GIS 数据及其格式,编程人员创建了若干开源库和 GIS 套件. GIS ...

  9. 新加了一块硬盘,在bios中可以看的到,在系统的磁盘管理器中看不到新加硬盘

    今天新加了一块硬盘,进入bios中可以看到新加的硬盘,但是进入系统后在磁盘管理及磁盘驱动器中都看不到.并且在设备管理器下其他设备出现了ATA channel1,前面显示感叹号,如下图所示: 而且电脑变 ...

  10. openstack之安全组管理

    命令概览 (nova-api)[root@cc07 /]# nova help|grep secgroup add-secgroup Add a Security Group to a server. ...