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

#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. 利用表格分页显示数据的js组件bootstrap datatable的使用

    前面展示了datatable的简单使用,还可以通过bootstrap结合datatable来使用,这样可以进一步美化datatable插件 <!DOCTYPE html> <html ...

  2. mysql5.7 pxc

    pxc优点总结:可以达到时时同步,无延迟现象发生完全兼容MySQL对于集群中新节点的加入,维护起来很简单数据的强一致性不足之处总结:只支持Innodb存储引擎存在多节点update更新问题,也就是写放 ...

  3. 【进阶1-4期】JavaScript深入之带你走进内存机制(转)

    这是我在公众号(高级前端进阶)看到的文章,现在做笔记 https://mp.weixin.qq.com/s/yK4DPKhkmkiroasWJMrJcw 阅读笔记 JS内存空间分为栈(stack).堆 ...

  4. c# 图片插入Excel

    引用COM:Microsoft Office 11.0 Object Library 引用类:    using System;    using System.Windows.Forms;    u ...

  5. Confluence 6 启用和禁用 Office 连接器

    如果你希望限制访问 Office 连接器的所有组件或者部分组件,你可以禁用整个插件也可以禁用插件中的某个模块. 希望启用或禁用 Office 连接器模块: 进入  > 基本配置(General ...

  6. 关于deepin linux15.6-15.9.1系统播放视频卡顿解决办法

    关于deepin linux15.6-15.9.1系统播放视频卡顿解决办法 chrome浏览器 关闭chrome硬件加速模式 设置>高级>使用硬件加速模式 注释:由于视频卡顿是因显卡驱动问 ...

  7. python魔法函数之__getattr__与__getattribute__

    getattr 在访问对象的属性不存在时,调用__getattr__,如果没有定义该魔法函数会报错 class Test: def __init__(self, name, age): self.na ...

  8. html超文本标记语言

     <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  9. 【转载】中文输入法下onKeyPress不能触发的问题

    onKeypress---->oninput https://segmentfault.com/a/1190000008820968

  10. 【docker】私有仓库搭建

    主要参考:http://blog.csdn.net/gqtcgq/article/details/51163558 假设我们在1.1.1.1:5000上搭建私人仓库,并在2.2.2.2上访问这个私人仓 ...