这题一看就筛质数就好啦, 可是这怎么筛啊, 一看题解, 怎么会有这么骚的操作。

#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 (看题解)的更多相关文章

  1. CodeForces - 1017F. The Neutral Zone (数学+Bitset存素数+素数筛优化)

    Notice: unusual memory limit! After the war, destroyed cities in the neutral zone were restored. And ...

  2. Codeforces 1017F The Neutral Zone 数论

    原文链接https://www.cnblogs.com/zhouzhendong/p/CF1017F.html 题目传送门 - CF1017F 题意 假设一个数 $x$ 分解质因数后得到结果 $x=p ...

  3. Codeforces 513E2 Subarray Cuts dp (看题解)

    我们肯定要一大一小间隔开来所以 把式子拆出来就是类似这样的形式 s1 - 2 * s2 + 2 * s3 + ...... + sn 然后把状态开成四个, 分别表示在顶部, 在底部, 在顶部到底部的中 ...

  4. Codeforces 822E Liar dp + SA (看题解)

    Liar 刚开始感觉只要开个dp[ i ][ j ][ 0 / 1 ]表示处理了s的前 i 个用了 k 段, i 是否是最后一段的最后一个字符 的 t串最长匹配长度, 然后wa24, 就gg了.感觉这 ...

  5. Codeforces 196E Opening Portals MST (看题解)

    Opening Portals 我们先考虑如果所有点都是特殊点, 那么就是对整个图求个MST. 想在如果不是所有点是特殊点的话, 我们能不能也 转换成求MST的问题呢? 相当于我们把特殊点扣出来, 然 ...

  6. Codeforces 725E Too Much Money (看题解)

    Too Much Money 最关键的一点就是这个贪心可以在sqrt(n)级别算出答案. 因为最多有sqrt(n)个不同的数值加入. 我们可以发现最优肯定加入一个. 然后维护一个当前可以取的最大值, ...

  7. Codeforces 750E New Year and Old Subsequence 线段树 + dp (看题解)

    New Year and Old Subsequence 第一感觉是离线之后分治求dp, 但是感觉如果要把左边的dp值和右边的dp值合起来, 感觉很麻烦而且时间复杂度不怎么对.. 然后就gun取看题解 ...

  8. Codeforces 547C/548E - Mike and Foam 题解

    目录 Codeforces 547C/548E - Mike and Foam 题解 前置芝士 - 容斥原理 题意 想法(口胡) 做法 程序 感谢 Codeforces 547C/548E - Mik ...

  9. Codeforces Round #668 (Div. 2)A-C题解

    A. Permutation Forgery 题目:http://codeforces.com/contest/1405/problem/A 题解:这道题初看有点吓人,一开始居然想到要用全排序,没错我 ...

随机推荐

  1. heidiSQL使用简介

    2017年12月5日09:49:42 星期二 HeidiSQL下载链接 1. 这个是免费的, 不用辛苦找破解码了, 也不用担心被破解软件装后门 2. 可以一次执行多条SQL语句分开选项卡显示 3. 可 ...

  2. Win7开机卡在Windows Update 35%的解决办法

    一台Win7老机器,多年未清理,用DISM++清理后,开机重启一直卡在Windows Update 35%转圈圈数小时,无法进入系统. 强制按关机键,F8进入安全模式依然同样现象. 查阅MSDN后,有 ...

  3. bootstrap的treeview使用方法

    首先引入文件: <link href="./css/bootstrap.css" rel="stylesheet"> <script src= ...

  4. js-DOM事件

    var EventUtil = { addHandler:function(elm,type,handler){//添加事件 if(elm.addEventListener){ elm.addEven ...

  5. C语言学习及应用笔记之二:C语言static关键字及其使用

    C语言有很多关键字,大多关键字使用起来是很明确的,但有一些关键字却要相对复杂一些.我们这里要说明的static关键字就是如此,它的功能很强大,相应的使用也就更复杂. 一般来说static关键字的常见用 ...

  6. mongo数据库的各种查询语句示例

    左边是mongodb查询语句,右边是sql语句.对照着用,挺方便. db.users.find() select * from users db.users.find({"age" ...

  7. python - 发送html格式的邮件

    import smtplibfrom email.mime.multipart import MIMEMultipartfrom email.mime.text import MIMETextfrom ...

  8. django rest framework(4)

    目录 一.分页 二.视图 三.路由 四.渲染器 一.分页 试问如果当数据量特别大的时候,你是怎么解决分页的? 方式a.记录当前访问页数的数据id 方式b.最多显示120页等 方式c.只显示上一页,下一 ...

  9. LeetCode(99):恢复二叉搜索树

    Hard! 题目描述: 二叉搜索树中的两个节点被错误地交换. 请在不改变其结构的情况下,恢复这棵树. 示例 1: 输入: [1,3,null,null,2]   1   /  3   \   2 输出 ...

  10. Linux基础实操六

    实操一: 临时配置网络(ip,网关,dns)+永久配置 #ifconfig ens33 192.168.145.134/24 #vim /etc/resolv.conf #route add defa ...