AC日记——[SCOI2009]游戏 bzoj 1025
思路:
和为n的几个数最小公倍数有多少种。
dp即可;
代码:
#include <bits/stdc++.h>
using namespace std;
#define maxn 1005
#define ll long long
int n,num;
ll dp[maxn][maxn],pi[maxn];
bool if_p[maxn];
void euler(int limit)
{
for(int i=;i<=limit;i++)
{
if(!if_p[i]) pi[++num]=i;
for(int j=;pi[j]*i<=limit&&j<=num;j++)
{
if_p[i*pi[j]]=true;
if(i%pi[j]==) break;
}
}
}
int main()
{
scanf("%d",&n),euler(n);
dp[][]=;
for(int i=;i<=num;i++)
{
for(int v=;v<=n;v++)
{
dp[i][v]=dp[i-][v];
for(ll pos=pi[i];pos<=v;pos*=pi[i])
{
dp[i][v]+=dp[i-][v-pos];
}
}
}
ll ans=;
for(int i=;i<=n;i++) ans+=dp[num][i];
cout<<ans+;
return ;
}
AC日记——[SCOI2009]游戏 bzoj 1025的更多相关文章
- AC日记——[SCOI2010]游戏 bzoj 1854
1854: [Scoi2010]游戏 Time Limit: 5 Sec Memory Limit: 162 MBSubmit: 4938 Solved: 1948[Submit][Status] ...
- 1025: [SCOI2009]游戏 - BZOJ
Description windy学会了一种游戏.对于1到N这N个数字,都有唯一且不同的1到N的数字与之对应.最开始windy把数字按顺序1,2,3,……,N写一排在纸上.然后再在这一排下面写上它们对 ...
- AC日记——国王游戏 洛谷 P1080
国王游戏 思路: 贪心+高精: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1005 struct Dat ...
- AC日记——色板游戏 洛谷 P1558
色板游戏 思路: sb题: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 struct Tre ...
- AC日记——图灵机游戏 codevs 2292
2292 图灵机游戏 时间限制: 1 s 空间限制: 64000 KB 题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Description [Shadow 1]第二题 ...
- AC日记——[Hnoi2017]影魔 bzoj 4826
4826 思路: 主席树矩阵加减+单调栈预处理: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 200005 ...
- AC日记——[LNOI2014]LCA bzoj 3626
3626 思路: 离线操作+树剖: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 #defin ...
- AC日记——[ZJOI2012]网络 bzoj 2816
2816 思路: 多个LCT: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 10005 #define l ...
- AC日记——[HNOI2014]世界树 bzoj 3572
3572 思路: 虚树+乱搞: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 300005 #define ...
随机推荐
- Codeforces Round #342 (Div. 2) C
C. K-special Tables time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 50 (Rated for Div. 2) C. Classy Numbers
C. Classy Numbers 题目链接:https://codeforces.com/contest/1036/problem/C 题意: 给出n个询问,每个询问给出Li,Ri,问在这个闭区间中 ...
- 手脱ACProtect V2.0(无Stolen Code)
1.载入PEID ACProtect V2.0 -> risco 2.载入OD > 00A04000 push ACP_Feed.0040A000 ; //入口点 0B104000 pus ...
- BI在连锁零售业应用
BI案例:BI在连锁零售业应用(ZT) Posted on 2015-08-25 09:31 xuzhengzhu 阅读(42) 评论(0) 编辑 收藏 第一部分:连锁零售企业上BI的必要性. 目前国 ...
- Linux Shell下执行sqlplus
转载自: http://www.cnblogs.com/include/archive/2011/12/30/2307889.html 以下方法解决了在linux下自动的删除创建用户 sqlplus ...
- 省队集训 Day3 吴清华
[题目大意] 给网格图,共有$n * n$个关键节点,横向.纵向距离均为$d$,那么网格总长度和宽度均为$(n+1) * d + 1$,最外围一圈除了四角是终止节点.要求每个关键节点都要通过线连向终止 ...
- centos6.4 yum安装nginx+mysql+php
1.配置防火墙,开启80端口.3306端口vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport ...
- SpringCloud Fegin超时重试源码
springCloud中最重要的就是微服务之间的调用,因为网络延迟或者调用超时会直接导致程序异常,因此超时的配置及处理就至关重要. 在开发过程中被调用的微服务打断点发现会又多次重试的情况,测试环境有的 ...
- ORA-02291:parent key not found
Hibernate operation: Could not execute JDBC batch update; SQL [insert into dchnpricecarchancesource ...
- FindQQByProcess
看网上有许多通过进程寻找QQ号的例子,看了一下,里面涉及的知识点还是比较多,但网上的兼容性不太好,而且没有给出匹配字符的来源,所以自己动手写了一下,顺便给出一些我调试的结果. #include &qu ...