题目:

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2608
Problem Description
Solving problem is a interesting thing. Yifenfei like to slove different problem,because he think it is a way let him more intelligent. But as we know,yifenfei is weak in math. When he come up against a difficult math problem, he always try to get a hand. Now the problem is coming! Let we
define T(n) as the sum of all numbers which are positive integers can divied n. and S(n) = T(1) + T(2) + T(3)…..+T(n).

Input
The first line of the input contains an integer T which means the number of test cases. Then T lines follow, each line consists of only one positive integers n. You may assume the integer will not exceed 2^31.

Output
For each test case, you should output one lines of one integer S(n) %2. So you may see the answer is always 0 or 1 .

Sample Input
3
1
2
3

Sample Output
1
0
0

Hint
Hint S(3) = T(1) + T(2) +T(3) = 1 + (1+2) + (1+3) = 8
S(3) % 2 = 0


分析:

赶脚这题非常坑。
打了一个S数组的表,简单yy了一下,什么卵都没发现。
后来有大神告诉我打T数组的表:
T=1的有1 2 4 8 9 16 18 25 32 36 49 50 64 72 81 98 100
简单yy了一下发现:
1.当n是完全平方数时T=1;
2.当n/2是完全平方数时T=1;
然后瞬间AC。

我的A(yang)C(wei)代码

#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
int T;
int main(){cin >> T;while (T--){int n;cin >> n;int ans=0;for (int i=1;;i++){if (i*i<=n) ans++;if (i*i*2<=n) ans++;if (i*i>n) break;}cout << ans%2 << endl;}return 0;
}

大神的代码

#include <iostream>
#include <cmath>
using namespace std;
int main(){int t;cin >> t;while (t--){int n;cin >> n;int ans=(int)sqrt(n*1.0)+(int)sqrt(n*1.0/2);cout << ans%2 << endl;}return 0;
}

附打表代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int calc(int x){int tot=0;for (int j=1;j<=x;j++){if (x%j==0) tot+=j;}return tot;
}
int main(){int t=0;for (int i=1;i<=100;i++){t=calc(i);printf("%d %d\n",i,t%2);}return 0;
}

HDU 2608 0 or 1 简单数论相关推荐

  1. 简单数论总结(整除)

    数论经典问题 整除的几个性质 数论小常识 模运算的分配率 模运算的放缩性 整除的几个性质 传递性:如果 a ∣ b a|b a∣b且 b ∣ c b|c b∣c,则 a ∣ c a|c a∣c 证明: ...

  2. vue.js 2.0实现的简单分页

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title&g ...

  3. 《Spring 3.0就这么简单》——1.6 展现层

    本节书摘来自异步社区<Spring 3.0就这么简单>一书中的第1章,第1.6节,作者: 陈雄华 , 林开雄著,更多章节内容可以访问云栖社区"异步社区"公众号查看 1. ...

  4. 《Spring 3.0就这么简单》——1.5 业务层

    本节书摘来自异步社区<Spring 3.0就这么简单>一书中的第1章,第1.5节,作者: 陈雄华 , 林开雄著,更多章节内容可以访问云栖社区"异步社区"公众号查看 1. ...

  5. GlideDemo【Glide3.7.0版本的简单使用以及圆角功能】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 本Demo主要记录Glide3.7.0版本的简单运用和实现圆角方案. 效果图 代码分析 Glide的centerCrop()和fit ...

  6. linux如何切换任务,linux 0.11中简单的任务切换中遇到的问题

    linux 0.11中简单的任务切换中遇到的问题 发布时间:2012-03-04 09:49:45来源:红联作者: 最近在学习linux0.11,用的是赵迥博士的一本书,其中有一个模仿Linus 当年 ...

  7. 数仓(十)从0到1简单搭建加载数仓DWS层

    数仓(一)简介数仓,OLTP和OLAP 数仓(二)关系建模和维度建模 数仓(三)简析阿里.美团.网易.恒丰银行.马蜂窝5家数仓分层架构 数仓(四)数据仓库分层 数仓 (五) 元数据管理系统解析 数仓( ...

  8. PL/0编译程序的简单实现

    文章目录 PL-0 代码参考 介绍 PL0编译程序的结构图与解释执行结构 函数功能说明表 过程和函数嵌套定义结构 总体流程图 GetCH() GetSym() BLOCK 语法描述 PL/0文法的EB ...

  9. hdu 5616 Jam's balance(简单dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5616 解题思路: 动态规划思想:dp[i][j]表示前i个数通过加减法是否可以等于j,如果为1,则表示 ...

  10. matlab数组平方的计算自定义函数_从零开始的matlab学习笔记——(38)简单数论计算函数:取整,gcd,lcm,质数,全排列...

    matlab应用--求极限,求导,求积分,解方程,概率统计,函数绘图,三维图像,拟合函数,动态图,傅里叶变换,随机数,优化问题....更多内容尽在个人专栏:matlab学习 翻了翻优化工具箱,发现内容 ...

最新文章

  1. ACM JAVA大数
  2. 图的最短路径(一级)
  3. oracle 学习第一天
  4. YOLO3 动漫人脸识别
  5. 系统学习数字图像处理之形态学分析补充(灰度级处理)
  6. MacOS Big Sur 11.2.1 (20D75) 纯净恢复版黑苹果镜像下载
  7. 伍德里奇计量经济学第六章计算机答案,伍德里奇计量经济学导论计算机习题第六章第13题c_6.13...
  8. SiamFC代码分析(architecture、training、test)
  9. 微信小程序+vant Weapp Slider 滑块实现滑动拖动计数器
  10. 红米K30Pro手机电路图纸 主板+小板电路原理图
  11. 给大家总结的一份白帽子成长进阶指南(内附学习资源)
  12. 高中数学:抛物线专题讲解利用韦达定理求解技巧
  13. 从历史故事看企业用人-之二--三国之东吴
  14. 【笔记整理】数字信号处理复习——FT、DTFT、DFT和FFT之间的关系
  15. react —— 解决报错之 Objects are not valid as a React child (found: [object HTMLDivElement]). If you meant
  16. “天翼阅读”APP用户体验
  17. 媲美微信的二维码识别库
  18. 计算机教室布置软木,软木照片墙布置,让孩子体验手工的乐趣
  19. 云服务器是怎么虚拟的,云服务器怎么虚拟化
  20. 扫地机器人充电插座布置_扫地机器人插座离地面多高合适 扫地机器人好不好用...

热门文章

  1. 中易云嵌入式网关丨性能卓越+性价比高+应用场景丰富
  2. 基于深度卷积神经网络的图像超分辨率重建(SRCNN) 学习笔记
  3. 摩拜单车骑行数据探索性分析【实战总结】
  4. 520到了,教你做个JavaWeb表白墙小项目
  5. 【Linux基础编程】help命令
  6. 【数学】微分(Differential)的定义,微分与导数的区别
  7. linux防病毒软件_十大Linux最佳防病毒软件-Linux防病毒软件列表!
  8. 完善:HTML5表单新特征简介与举例——张鑫旭
  9. iOS8新功能新特性
  10. [5机器学习]python计算机视觉应用-图片内容识别