题干中给出函数公式:

  

其中pi为n的每个素因数,ei为其个数。设该函数为F(x),其意义为x的约数之和。问在1-n中有多少x,令F(x)为偶数。

分析:设f(p)为(p^(e+1)-1)/(p-1)。若F(x)为奇数,则任意的f(pi)都为奇数。

f(p)还可以写成:f(p)= (1+p^1+p^2+...+p^e)。则当p==2时,f(p)肯定是奇数(偶数+1);当p!=2时,因为p是素数,所以p一定是奇数。则e偶数时,f(p)为奇数。

所以一个数x若可以表示为 (2^2k1)*(3^2k2)*(5^2k3)*....*(pn^2kn)的形式,即x是平方数或2x是平方数的时候,其F(x)为奇。

那么对给定的n,sqrt(n)+sqrt(n/2)的值就是1-n中约数和为奇数的个数。相减得到答案

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = ; int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int T,N,a,cas=;
LL n;
scanf("%d",&T);
while(T--){
scanf("%lld",&n);
LL ans = n - (LL)sqrt(n/) - (LL)sqrt(n);
printf("Case %d: %lld\n",cas++,ans);
}
return ;
}

最新文章

  1. 职责链模式(chain of responsibility Pattern)
  2. SQL Server性能影响的重要结论
  3. 30天,O2O速成攻略【7.19深圳站】
  4. PCB参数计算神器-Saturn PCB Design Toolkit下载及安装指南
  5. action找不到
  6. jquery ajax 跨域提交(附IE浏览器解决方案)
  7. UVa 496 - Simply Subsets
  8. WinCE中断结构分析
  9. Maven引入自定义jar包
  10. AJAX 基本结构 数据加载
  11. Make ProgressBar Vertical
  12. memcached未授权
  13. Ibatis.Net 表连接查询学习(五)
  14. Android Studio 错误: 非法字符: &amp;#39;\ufeff&amp;#39; 解决方式|错误: 须要class, interface或enum
  15. c#如何仅在datatgirdview控件的头部(列名处)添加右键菜单
  16. Error:Could not find com.github.dcendents:android-maven-plugin:1.5.
  17. 基于JDK1.8的String源码学习笔记
  18. python实现socket上传下载文件-进度条显示
  19. 10 华电内部文档搜索系统 search04
  20. request设置属性 一般当做下一个页面的结果集

热门文章

  1. Java异常框架设计
  2. 百度富文本编辑器UEditor报【类型&quot;Uploader&quot;同时存在】错误
  3. 那些年我读过的Blog(Ⅰ)
  4. js计算百分比
  5. 【ASK】git使用中出现Permission denied (publickey).
  6. Jquery实现Bootstrap树形列表
  7. npm安装express 公司上网设置代理
  8. iOS - 导航栏UINavigationController经常使用属性
  9. tomcat报错-----》Unable to open debugger port IDEA Unable to open debugger port
  10. 火狐 a 标签 download 属性,要在 a 标签添加到页面中才生效;