链接:

https://vjudge.net/problem/LightOJ-1336

题意:

Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all divisors of a number. For example σ(24) = 1+2+3+4+6+8+12+24=60. Sigma of small numbers is easy to find but for large numbers it is very difficult to find in a straight forward way. But mathematicians have discovered a formula to find sigma. If the prime power decomposition of an integer is

Then we can write,

For some n the value of σ(n) is odd and for others it is even. Given a value n, you will have to find how many integers from 1 to n have even value of σ.

思路:

考虑质数的约数和可以看作\((1+p_1^1+p_1^2+...+p_1^{k1})*(1+p_2^1+p_2^2+...+p_2^{k2})...\)

考虑和为奇数情况。

存在素因子2时,(1+2^n)为奇数,则和为奇数。

其他素因子为奇数,奇数乘奇数为奇数,1+偶数为奇数,偶数乘奇数为偶数,则只有素因子的指数为偶数时满足和为奇数。

由此得到其他数都为平方数。或者时平方数*2

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map> using namespace std;
typedef long long LL;
const int INF = 1e9; const int MAXN = 1e6+10;
const int MOD = 1e9+7; LL n; int main()
{
int t, cnt = 0;
scanf("%d", &t);
while(t--)
{
printf("Case %d:", ++cnt);
scanf("%lld", &n);
LL tmp = n;
tmp -= (LL)sqrt(n);
tmp -= (LL)sqrt(n/2);
printf(" %lld\n", tmp);
} return 0;
}

LightOJ - 1336 - Sigma Function(质数分解)的更多相关文章

  1. LightOJ 1336 Sigma Function(数论 整数拆分推论)

    --->题意:给一个函数的定义,F(n)代表n的所有约数之和,并且给出了整数拆分公式以及F(n)的计算方法,对于一个给出的N让我们求1 - N之间有多少个数满足F(x)为偶数的情况,输出这个数. ...

  2. LightOJ 1336 - Sigma Function

    原题链接 基础数论中很经典的一道题 题意 给出了σ(n)的计算公式,让你找出整数1-n中有多少对应σ(n)的值是偶数. 思路 观察σ(n)的公式发现,每一个乘项都是 (piei+1 - 1) / (p ...

  3. LightOJ 1336 Sigma Function 算数基本定理

    题目大意:f(n)为n的因子和,给出 n 求 1~n 中f(n)为偶数的个数. 题目思路:算数基本定理: n=p1^e1*p2^e1 …… pn^en (p为素数): f(n)=(1+p1+p1^2+ ...

  4. LightOJ - 1336 Sigma Function(约数和+整数拆分)

    题干中给出函数公式: 其中pi为n的每个素因数,ei为其个数.设该函数为F(x),其意义为x的约数之和.问在1-n中有多少x,令F(x)为偶数. 分析:设f(p)为(p^(e+1)-1)/(p-1). ...

  5. LightOJ 13361336 - Sigma Function (找规律 + 唯一分解定理)

    http://lightoj.com/volume_showproblem.php?problem=1336 Sigma Function Time Limit:2000MS     Memory L ...

  6. 1336 - Sigma Function

    1336 - Sigma Function   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB S ...

  7. light oj 1336 sigma function

    常用的化简方法(高中就常用了):     p^(e+1)-1/p-1=             [ p^(e+1) -p + (p-1) ]/ (p-1) = p*(p^e-1)/(p-1) + 1  ...

  8. LightOJ1336 Sigma Function —— 质因子分解、约数和为偶数

    题目链接:https://vjudge.net/problem/LightOJ-1336 1336 - Sigma Function    PDF (English) Statistics Forum ...

  9. 1336 - Sigma Functio

    1336 - Sigma Function Sigma function is an interesting function in Number Theory. It is denoted by t ...

随机推荐

  1. Python解释器安装与环境变量添加

    Python解释器安装与环境变量添加 Python解释器安装(3.6和2.7): www.python.org这个是python解释器的官网,一定要牢记. 鉴于市场上有两种python版本(2和3), ...

  2. day32——进程、操作系统

    day32 进程的基础 程序 一堆静态的代码文件 进程 一个正在运行的程序进程.抽象的概念 被谁运行? 由操作系统操控调用交于CPU运行 ​ 操作系统 管理控制协调计算机中硬件与软件的关系 操作系统的 ...

  3. mysql实践一:SQL基础

    mysql简介 mysql是有名的开放源代码关系型数据库.它最早是AB公司开源的,后来到Sun公司手中.之后Sun公司被Oracle公司收购,mysql就归Oracle所有.从此mysql走向商业化, ...

  4. pythony--运算符

    python运算符 运算符表达式 python运算符:   赋值运算符.算数运算符.关系运算符.逻辑运算符 python表达式: 是将不同的数据(包括变量.函数)用运算符号按一定规则连接起来的一种式子 ...

  5. AX2009取销售订单的税额

    直接用以下方法即可: Tax::calcTaxAmount(salesLine.TaxGroup, salesLine.TaxItemGroup, systemDateGet(),    salesL ...

  6. 排Bug技巧

    排Bug技巧 什么是Bug? Bug一词的英文原意是"臭虫"或"虫子".但是现在,在电脑系统或游戏程序中,如果隐藏着的一些未被发现的缺陷或问题,可被人利用,人们 ...

  7. centos7+ 在线yum安装docker-ce

    yum install -y yum-utils   //扩展yum功能 yum-config-manager --add-repo http://mirrors.aliyun.com/docker- ...

  8. MES系统之设备管理的基础功能

    设备是制造企业进行生产的主要物质技术基础,制造企业的生产率.产品质量.生产成本都与设备直接相关.因此,正确使用.定时保养.及时检修维护设备,并对设备的运行性能进行分析,使设备处于良好的状态,才能保证企 ...

  9. Oracle.EntityFrameworkCore使用时报错:ORA-00933:SQL命令未正确结束

    如果你在使用 Oracle.EntityFrameworkCore 在执行一些分页查询或者其他数据操作时,遇到“ORA-00933:SQL命令未正确结束”, 请先检查你的DbContext中UseOr ...

  10. Web应用的生命周期(客户端)

    典型的一个Web应用的生命周期从用户在浏览器输入一串URL,或者单击一个链接开始(就是访问一个页面).而这个生命周期的结束就是我们关闭这个页面. 响应流程: 用户输入一个 URL(生命周期开始) 客户 ...