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. maven3 学习

    主要参考博文:http://www.cnblogs.com/yjmyzz/p/3495762.html 修正: 1.下载maven 3.1.1 先到官网http://maven.apache.org/ ...

  2. Shortest Unsorted Continuous Subarray LT581

    Given an integer array, you need to find one continuous subarray that if you only sort this subarray ...

  3. Gazebo: Could not find parameter robot_description on parameter server

    robot_state_publisher looks for the parameter "robot_description" by default. The robot_st ...

  4. Zxing2.1扫描取景框变形问题解决

    修改竖屏扫描的贴子,2.0之前的都很适用.可是到了2.1,有些贴子的做法可以将扫描框改为竖屏,但是取景框里扫描到的东西是变形的(扁的),本人仔细研究一番,终于解决了这个问题,下面贴出解决办法: 1.修 ...

  5. spring学习 十四 注解AOP 通知传递参数

    我们在对切点进行增强时,不建议对切点进行任何修改,因此不加以使用@PointCut注解打在切点上,尽量只在Advice上打注解(Before,After等),如果要在通知中接受切点的参数,可以使用Jo ...

  6. python入门之深浅copy

    a1=["a","b","c","aa"] b1=a1 a1[0]=" print(a1,b1) 此时结果为: ...

  7. Java第11章笔记

    什么是类,什么是对象 举例说明什么是类,什么是对象? 一句话:万物皆对象 类的概念:类是具有相同属性和服务的一组对象的集合. 1.为属于该类的所有对象提供了统一的抽象描述,其内部包括属性和服务两个部分 ...

  8. 数学小知识点整理(TBC)

    文章目录 前言 素数与同余 线性筛部分 素数 线性递推逆元 指数循环节降幂 当求逆元时模数与求逆元的数有可能不互质时的处理方法 一个神奇的结论 拓展欧拉定理 杂乱的一些性质/技巧 二进制枚举子集 异或 ...

  9. 2019.01.02 bzoj3513: [MUTC2013]idiots(fft)

    传送门 fftfftfft经典题. 题意简述:给定nnn个长度分别为aia_iai​的木棒,问随机选择3个木棒能够拼成三角形的概率. 思路:考虑对于木棒构造出生成函数然后可以fftfftfft出两个木 ...

  10. MFC连接MySQL

    其实,以前弄过sql,mysql应该是顺理成章很简单的事情,但很无奈,傻傻地弄了很久,还请教了别人,别人告诉我的跟我在网上查到的都是一样的,但还是不行,归根接地就是“mysql-connector-o ...