Codeforces 1017F The Neutral Zone (看题解)
这题一看就筛质数就好啦, 可是这怎么筛啊, 一看题解, 怎么会有这么骚的操作。
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long
using namespace std; const int N = 1e5 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-; unsigned int n,a,b,c,d;
unsigned int ans;
bitset<> bit; inline unsigned int f(unsigned int x){
return a * x * x * x + b * x * x + c * x + d;
}
inline unsigned int getVal(unsigned int x){
unsigned int ret = f(x);
unsigned int tmp = ;
for(unsigned int i = n / x; i; i /= x)
tmp += i;
return ret * tmp;
} int main(){
scanf("%u%u%u%u%u",&n,&a,&b,&c,&d);
ans = getVal() + getVal();
bit.reset();
for(unsigned int i = ; i <= n; i++){
if(i % == || i % == ) {
continue;
}
if(bit[i / ] == ) {
ans += getVal(i);
for(unsigned int j = i; j <= n; j += i){
if(j % == || j % == ) continue;
bit[j / ] = ;
}
}
}
printf("%u\n",ans);
return ;
}
/*
*/
Codeforces 1017F The Neutral Zone (看题解)的更多相关文章
- CodeForces - 1017F. The Neutral Zone (数学+Bitset存素数+素数筛优化)
Notice: unusual memory limit! After the war, destroyed cities in the neutral zone were restored. And ...
- Codeforces 1017F The Neutral Zone 数论
原文链接https://www.cnblogs.com/zhouzhendong/p/CF1017F.html 题目传送门 - CF1017F 题意 假设一个数 $x$ 分解质因数后得到结果 $x=p ...
- Codeforces 513E2 Subarray Cuts dp (看题解)
我们肯定要一大一小间隔开来所以 把式子拆出来就是类似这样的形式 s1 - 2 * s2 + 2 * s3 + ...... + sn 然后把状态开成四个, 分别表示在顶部, 在底部, 在顶部到底部的中 ...
- Codeforces 822E Liar dp + SA (看题解)
Liar 刚开始感觉只要开个dp[ i ][ j ][ 0 / 1 ]表示处理了s的前 i 个用了 k 段, i 是否是最后一段的最后一个字符 的 t串最长匹配长度, 然后wa24, 就gg了.感觉这 ...
- Codeforces 196E Opening Portals MST (看题解)
Opening Portals 我们先考虑如果所有点都是特殊点, 那么就是对整个图求个MST. 想在如果不是所有点是特殊点的话, 我们能不能也 转换成求MST的问题呢? 相当于我们把特殊点扣出来, 然 ...
- Codeforces 725E Too Much Money (看题解)
Too Much Money 最关键的一点就是这个贪心可以在sqrt(n)级别算出答案. 因为最多有sqrt(n)个不同的数值加入. 我们可以发现最优肯定加入一个. 然后维护一个当前可以取的最大值, ...
- Codeforces 750E New Year and Old Subsequence 线段树 + dp (看题解)
New Year and Old Subsequence 第一感觉是离线之后分治求dp, 但是感觉如果要把左边的dp值和右边的dp值合起来, 感觉很麻烦而且时间复杂度不怎么对.. 然后就gun取看题解 ...
- Codeforces 547C/548E - Mike and Foam 题解
目录 Codeforces 547C/548E - Mike and Foam 题解 前置芝士 - 容斥原理 题意 想法(口胡) 做法 程序 感谢 Codeforces 547C/548E - Mik ...
- Codeforces Round #668 (Div. 2)A-C题解
A. Permutation Forgery 题目:http://codeforces.com/contest/1405/problem/A 题解:这道题初看有点吓人,一开始居然想到要用全排序,没错我 ...
随机推荐
- svn服务器的搭建备份和还原和svnmanager的使用
svn服务器的搭建备份和还原和svnmanager的使用 一.svn服务端软件的安装和配置 1.安装svn版本库软件 # yum install -y subversion 2.建立svn版本库数据存 ...
- PHP IDE选择标准
2017年11月17日09:35:01 这里记录一下PHP IDE的选择标准 1. 是否有错误提示, 对于一些 `缺少分号`, `花括号不配对`, `变量未定义就使用`等待的提示是要有的 2. 代码 ...
- Android App增量升级
移动互联网主打的就是用户体验和产品的快速迭代,通过用户反馈和用户行为跟踪及时调整产品方向,这样才能持续保持生命力和创造力.说的接地气点就是,你频繁的升级更新,有时只是修复了几个bug或者微调了下界面, ...
- Apache服务器和tomcat服务器有什么区别(转)
Apache与Tomcat都是Apache开源组织开发的用于处理HTTP服务的项目,两者都是免费的,都可以做为独立的Web服务器运行.Apache是Web服务器而Tomcat是Java应用服务器. A ...
- [PHP]PDO各方法在发生MYSQL断开时的反应
1.mixed PDO::errorCode ( void ) 如果单独执行此语句,并不能判断此时MYSQL是否已断开,它返回最上一次对MYSQL操作的错误码 2.public array PDO:: ...
- Python- 索引 B+数 比如书的目录
1.索引 为何要有索引? 一般的应用系统,读写比例在10:1左右,而且插入操作和一般的更新操作很少出现性能问题, 在生产环境中,我们遇到最多的,也是最容易出问题的,还是一些复杂的查询操作, 因此对查询 ...
- 详解 HTTPS、TLS、SSL、HTTP区别和关系
一.什么是HTTPS.TLS.SSL HTTP也称作HTTP over TLS.TLS的前身是SSL,TLS 1.0通常被标示为SSL 3.1,TLS 1.1为SSL 3.2,TLS 1.2为SSL ...
- es6 super关键字
rhttp://es6.ruanyifeng.com/#docs/class-extends super关键字,既可以当作函数使用,也可以当作对象使用.这俩种的使用是不一样的 第一种:函数使用 代表父 ...
- jQuery-lazyload参数
1.placeholder placeholder:'图片地址',用图片提前占据将要加载的图片的位置. 2.effect effect:‘fadeIn’ 表示用何种效果载入,eg:show()直接加载 ...
- 使用open live writer客户端写博客
注:Windows Live Writer 已经停止更新,建议安装 Open Live Writer,下载地址: http://openlivewriter.org/ 使用open live writ ...