https://codeforces.com/contest/1174/problem/E

dp

好题

*(if 满足条件)

满足条件 *1

不满足条件 *0

///这代码虽然写着方便,但是常数有点大

 #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long const double eps=1e-;
const ll inf=1e9;
const ll mod=1e9+;
const int maxn=1e6+; /*
dp题
检查:
1.认真检查公式
2.认真检查代码
3.造一个规模适中的数据
手动推导
对应程序的结果
判断是否相同
*/ ///+1 20->21 2->3
///0->-1 前面加一个辅助数组,这个数组里的所有元素数值为0
///x1*y1+x2*y2+x3*y3+...x20*y20 有可能会超long long, 所以所有乘法运算后面都加%mod
///1e18*k k<=9
int f[maxn][21][3],v[21][3]; int main()
{
int n,two,three,i,j,k;
scanf("%d",&n);
two=log(n+eps)/log();///+eps
three=(1.0*n/(<<two)>=1.5);
for (i=;i<=two;i++)
for (j=;j<=three;j++)
v[i][j]=n/((<<i)*(j==?:)); f[][two][]=;
if (three==)
f[][two-][]=;
for (i=;i<=n;i++)
for (j=;j<=two;j++)
for (k=;k<=three;k++)
///乘1ll,最后强制转换long long 转 int
f[i][j][k]=( 1ll*f[i-][j][k]*(v[j][k]-(i-))*((v[j][k]-(i-))>=)%mod + 1ll*f[i-][j+][k]*(v[j][k]-v[j+][k])*(j!=two)%mod + 1ll*f[i-][j][k+]*(v[j][k]-v[j][k+])*(k!=three)%mod )%mod;
printf("%d",f[n][][]);
return ;
}

推荐比如说这个xiongdi的代码

https://codeforces.com/contest/1174/submission/56391704

超内存的代码

 #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long const double eps=1e-;
const ll inf=1e9;
const ll mod=1e9+;
const int maxn=1e6+; /*
dp题
检查:
1.认真检查公式
2.认真检查代码
3.造一个规模适中的数据
手动推导
对应程序的结果
判断是否相同
*/ ///+1 20->21 2->3
///0->-1 前面加一个辅助数组,这个数组里的所有元素数值为0
///x1*y1+x2*y2+x3*y3+...x20*y20 有可能会超long long, 所以所有乘法运算后面都加%mod
///1e18*k k<=9
ll f[maxn][21][3],v[21][3]; int main()
{
int n,two,three,i,j,k;
scanf("%d",&n);
two=log(n+eps)/log();///+eps
three=(1.0*n/(<<two)>=1.5);
for (i=;i<=two;i++)
for (j=;j<=three;j++)
v[i][j]=n/((<<i)*(j==?:)); f[][two][]=;
if (three==)
f[][two-][]=;
for (i=;i<=n;i++)
for (j=;j<=two;j++)
for (k=;k<=three;k++)
f[i][j][k]=( f[i-][j][k]*(v[j][k]-(i-))*((v[j][k]-(i-))>=)%mod + f[i-][j+][k]*(v[j][k]-v[j+][k])*(j!=two)%mod + f[i-][j][k+]*(v[j][k]-v[j][k+])*(k!=three)%mod )%mod; printf("%lld",f[n][][]);
return ;
}

Codeforces Round #563 (Div. 2) E. Ehab and the Expected GCD Problem的更多相关文章

  1. Codeforces Round #563 (Div. 2) C. Ehab and a Special Coloring Problem

    链接:https://codeforces.com/contest/1174/problem/C 题意: You're given an integer nn. For every integer i ...

  2. Codeforces Round #525 (Div. 2)E. Ehab and a component choosing problem

    E. Ehab and a component choosing problem 题目链接:https://codeforces.com/contest/1088/problem/E 题意: 给出一个 ...

  3. Codeforces Round #525 (Div. 2)D. Ehab and another another xor problem

    D. Ehab and another another xor problem 题目链接:https://codeforces.com/contest/1088/problem/D Descripti ...

  4. Codeforces Round #563 (Div. 2) B. Ehab Is an Odd Person

    链接:https://codeforces.com/contest/1174/problem/B 题意: You're given an array aa of length nn. You can ...

  5. Codeforces Round #563 (Div. 2) A. Ehab Fails to Be Thanos

    链接:https://codeforces.com/contest/1174/problem/A 题意: You're given an array aa of length 2n2n. Is it ...

  6. Codeforces Round #563 (Div. 2) F. Ehab and the Big Finale

    后续: 点分治标程 使用father数组 比使用vis数组优秀(不需要对vis初始化) https://codeforces.com/problemset/problem/1174/F https:/ ...

  7. Codeforces Round #525 (Div. 2) D. Ehab and another another xor problem(待完成)

    参考资料: [1]:https://blog.csdn.net/weixin_43790474/article/details/84815383 [2]:http://www.cnblogs.com/ ...

  8. Codeforces Round #525 (Div. 2) E. Ehab and a component choosing problem 数学

    题意:给出树 求最大的sigma(a)/k k是选取的联通快个数   联通快不相交 思路: 这题和1个序列求最大的连续a 的平均值  这里先要满足最大平均值  而首先要满足最大  也就是一个数的时候可 ...

  9. Codeforces Round #525 (Div. 2) D. Ehab and another another xor problem(交互题 异或)

    题目 题意: 0≤a,b<2^30, 最多猜62次. 交互题,题目设定好a,b的值,要你去猜.要你通过输入 c d : 如果 a^c < b^d ,会反馈 -1 : 如果 a^c = b^ ...

随机推荐

  1. Linux下载工具-Wget

    一.安装 进入系统后执行: # yum install wget 二.常用命令使用 以下亲测可用:[文件保存在当前命令执行的文件夹中] 1.wget下载单个文件 # wget url(文件地址,如ht ...

  2. nginx proxy_pass设置

    NGINX服务器的反向代理PROXY_PASS配置方法讲解 https://www.cnblogs.com/lianxuan1768/p/8383804.html Nginx配置proxy_pass转 ...

  3. linux 虚拟机网卡配置

     第一种虚拟机   我们常用的虚拟机vmware虚拟机 今天为了学习ngnix,所以配了两台虚拟机.一个centos7 ,一个redhat. 哇啦哇啦安装,so easy,对吧....我选择的是精简版 ...

  4. Centos6安装破解Confluence6.3.1

    confluence是一个专业的企业知识管理与协同软件,可以用于构建企业wiki.通过它可以实现团队成员之间的协作和知识共享 安装和破解包百度网盘地址: 链接:https://pan.baidu.co ...

  5. 【CSS3】rgba与opacity

    RGBA 语法 R:红色值.正整数 | 百分数 G:绿色值.正整数 | 百分数 B:蓝色值.正整数| 百分数 A:透明度.取值0~1之间 为什么要用RGBA而不用opacity 因为在项目中需要用到一 ...

  6. 【Leetcode周赛】从contest1开始。(一般是10个contest写一篇文章)

    注意,以前的比赛我是自己开了 virtual contest.这个阶段的目标是加快手速,思考问题的能力和 bug-free 的能力. 前面已经有了100个contest.计划是每周做三个到五个cont ...

  7. Python中 将数据插入到Word模板并生成一份Word

    搬运出处: https://blog.csdn.net/DaShu0612/article/details/82912064

  8. C++中创建对象的时候加括号和不加括号的区别(转)

    c++创建对象的语法有----- 1 在栈上创建 MyClass a; 2 在堆上创建加括号 MyClass *a= new MyClass(); 3 不加括号 MyClass *a = new My ...

  9. 记录我个人对Telegram的了解

    对Telegram(电报) 开始的了解是以为提供了Telegram API,就可以基于它进行开发自己的即时通讯(Instant Messaging)程序. 大概使用过: webogram 和 tele ...

  10. Java中static关键字的定义

    1.static存在的主要意义 static的主要意义是在于创建独立于具体对象的域变量或者方法.以致于即使没有创建对象,也能使用属性和调用方法! static关键字还有一个比较关键的作用就是 用来形成 ...