2021年4月14日

O(N) 筛素数


const int N = 1e6 + 50;
bool vis[N];
vector<int> primes;

void init() {
for (int i = 2; i < N; ++i) {
if (!vis[i]) primes.push_back(i);
for (int v : primes) {
if (v * i >= N) break;
vis[v * i] = true;
if (i % v == 0) break;
}
}
}

bool vis[N];
int phi[N], minFactor[N], plist[10];
void initPrime() {
  cnt 0;
  phi[1] = 1;
  int x;
  for (int 2Ni++) {
    if (!vis[i]) {
      plist[cnt++] = i;
      phi[i] = 1;
      minFactor[i] = i;
    }
    for (int 0cnt && plist[k] * Nk++) {
      x plist[k] * i;
      vis[x] = true;
      minFactor[x] = plist[k];
      if (plist[k] == 0) {
        phi[x] = phi[i] * plist[k];
        break;
      } 
else {
        phi[x] = phi[i] * (plist[k] - 1);
      }
    }
  }
}

posted @ 2021-04-14 03:44 成诺 阅读(76) 评论(0) 推荐(0)

2019年8月19日

如何手动触发谷歌浏览器自动填充密码

摘要: 谷歌浏览器自带了一个密码管理器功能,这个功能应该大家或多或少都应该有听说过或者使用过这个功能。 这个功能主要的内容就是,当用户在网页上输入了用户名,密码登陆或者修改密码表单提交时会触发自动保存密码这个功能。如果用户所使用的电脑不是公共电脑,就可以保存此密码。 在登陆页面表单中,谷歌浏览器会拉出自动表 阅读全文

posted @ 2019-08-19 06:28 成诺 阅读(8460) 评论(0) 推荐(0)

2019年6月28日

个人推荐的Java邮件配置

摘要: 这个配置既可以保证服务器端兼容性,又能保证账号密码安全,所以个人推荐使用。 以上配置是使用spring mail的,如果未使用spring mail,可以尝试以下配置 阅读全文

posted @ 2019-06-28 16:48 成诺 阅读(372) 评论(0) 推荐(0)

2019年2月16日

名人名言——摘录自编程随想的博客

摘要: 1. 一个人的价值,在于他贡献了什么,而不在于他获得了什么!——爱因斯坦2. 你若喜爱你自己的价值,你就得给世界创造价值!——歌德3. 我从来不把安逸和享乐当作生活目的;对这种伦理基础,我称之为【猪栏的理想】——爱因斯坦4. 未经反思自省的人生不值得去过The unexamined life is 阅读全文

posted @ 2019-02-16 00:09 成诺 阅读(2011) 评论(0) 推荐(0)

2016年10月21日

Pat 1003 甲级

摘要: #include <cstdlib> #include <cstring> #include <iostream> #include <cstdio> #include <cassert> using namespace std; #define N 505 int a[N]; long long 阅读全文

posted @ 2016-10-21 16:14 成诺 阅读(260) 评论(0) 推荐(0)

2012年4月2日

java.math.BigDecimal.stripTrailingZeros 对0的处理时注意了

摘要: 测试一下这个 System.out.println(new BigDecimal("0.0000").stripTrailingZeros()); JDK 7 0.0000 JDK8+ 0 阅读全文

posted @ 2012-04-02 15:08 成诺 阅读(2878) 评论(0) 推荐(0)

2011年8月22日

hdu 3065 刚A了道题,很艰难,贴下代码。。

摘要: 病毒侵袭持续中http://acm.hdu.edu.cn/showproblem.php?pid=3065Accepted3065375MS8732K3043BC++// 今天好不容易把自动机学会了,AC了一道题,不过我自己写的代码还有看不懂的,请大牛指教。。。。#include <cstdlib>#include <cstdio>#include <cstring>#include <cassert>#include <queue>#include <cctype> // 用于 isupper, 判断是否为大写字母#in 阅读全文

posted @ 2011-08-22 11:02 成诺 阅读(492) 评论(1) 推荐(0)

2011年7月16日

poj 2362

摘要: POJ 2362 Square 最近不行了,这么个简单的深搜还超时了N多次/* 阅读全文

posted @ 2011-07-16 12:20 成诺 阅读(460) 评论(0) 推荐(0)

2011年7月11日

没事做,贴个代码。

摘要: Problem E Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s):11Accepted Submission(s): 2Problem DescriptionThe light travels in a straight line and always goes in the minimal path between two points, are the basic laws of optics.Now, our problem is th 阅读全文

posted @ 2011-07-11 16:28 成诺 阅读(227) 评论(0) 推荐(0)

2011年5月25日

QQ申请器, vbs的

摘要: Dim nickname,password,year,month,day nickname="badapple" '昵称' password="your password here" '密码' year=1992 month=1 day=1 'Dim a,toyear toyear=2011 Set 阅读全文

posted @ 2011-05-25 19:28 成诺 阅读(457) 评论(1) 推荐(0)

导航

< 2025年6月 >
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 1 2 3 4 5
6 7 8 9 10 11 12
点击右上角即可分享
微信分享提示