Description

Input

Output

Sample Input

3

Sample Output

1

Data Constraint

Solution

  • 这题我的方法是打表找规律,可以发现答案可用枚举偶数和系数推出。

  • 实际上也可以用下式推出答案:

    Gcd(a,b)≤a−b≤a xor b

    Gcd(a,b)\leq a-b\leq a\ xor\ b

Code

#include<cstdio>
using namespace std;
int n,ans;
int main()
{scanf("%d",&n);for(int i=3;i<=n;i+=2){int k=n/i;for(int j=1;j<=k;j++){int p=i*j;if((p^p-j)==j) ans++;}}printf("%d",ans);return 0;
}

JZOJ 5197. 【NOIP2017提高组模拟7.3】C相关推荐

  1. NOIP2017提高组模拟赛4 (总结)

    NOIP2017提高组模拟赛4 (总结) 第一题 约数 设K是一个正整数,设X是K的约数,且X不等于1也不等于K. 加了X后,K的值就变大了,你可以重复上面的步骤.例如K= 4,我们可以用上面的规则产 ...

  2. JZOJ 5182. 【NOIP2017提高组模拟6.29】码灵鼠

    Description 码零鼠是一只很喜欢mx数学的神犇,上面那个不是ta本人的样子.这天,ta在研究一个神奇的数列,这个数列是这样的: a0 = 1 an = ai + aj (n>=1, i ...

  3. JZOJ 4932. 【NOIP2017提高组模拟12.24】B

    Description 现在你有 NN 个数,分别为 A1,A2,-,ANA1,A2,-,AN ,现在有M组询问需要你回答.每个询问将会给你一个L和R(L<=R)(L,保证 MaxAi−MinA ...

  4. JZOJ 5195. 【NOIP2017提高组模拟7.3】A

    Description Input Output Sample Input 7 3 Sample Output 4 Data Constraint Solution 这是一道经典的DP问题了,也可以把 ...

  5. JZOJ 5186. 【NOIP2017提高组模拟6.30】tty's home

    Description Input Output Sample Input input 1: 5 1 1 1 1 1 1 2 2 3 3 4 4 5 input 2: 5 0 1 0 1 0 1 2 ...

  6. JZOJ 5185. 【NOIP2017提高组模拟6.30】tty's sequence

    Description Input Output Sample Input input 1: 6 3 1 1 1 0 0 0 input 2: 6 3 1 1 0 1 0 0 input 3: 6 3 ...

  7. JZOJ 5184. 【NOIP2017提高组模拟6.29】Gift

    Description Input Output Solution 这题看上去有些 01背包,但是细节上却大有不同. 先将价格从小到大排序,由于剩余的钱什么也不能买, 所以当没购买的物品中价格最小的为 ...

  8. JZOJ 5183. 【NOIP2017提高组模拟6.29】小T的钢琴

    Description Input Output Sample Input 9 3 A1 B2 C3 D4 E5 D4.0 C3.0 B2.0 A1.0[nya] 3 A1 A1.0 E5[qwert ...

  9. JZOJ 5177. 【NOIP2017提高组模拟6.28】TRAVEL

    Description Input Output Sample Input 4 4 1 2 1 10 2 4 3 5 1 3 1 5 2 4 2 7 Sample Output 6 2 3 4 5 6 ...

最新文章

  1. drupal7获取当前路径别名
  2. 算法笔记之分支限界法
  3. 集团化后的挚文还有很多“新故事”可以讲
  4. 没有人会告诉您乘坐飞机时的几个事实 但是您一定要知道
  5. Android之提示Cannot call this method while RecyclerView is computing a layout or scrolling
  6. C++中 list与vector的区别
  7. 谷歌跟oracle_谁赢得了Google VS Oracle? 开发人员赢了。
  8. [前台]---js中方法的强制返回和java中方法的强制返回
  9. 阿里云 MaxCompute 2018-09 新功能发布
  10. bzoj1232[Usaco2008Nov]安慰奶牛cheer*
  11. [******] 堆排序
  12. 【报告分享】2019互联网大会大佬演讲实录 (附11个演讲文档下载链接)
  13. (转)MTK softkey流程 必看
  14. java中加载窗口的函数_Java函数调用 - playgame的个人页面 - OSCHINA - 中文开源技术交流社区...
  15. Tensorflow:操作执行原理
  16. 触摸屏学习:利用状态机编程
  17. 如何在vue项目中增加网页logo
  18. Coded UI Test(二)创建一个Coded UI Test
  19. 7-12 愿天下有情人都是失散多年的兄妹 (25分)
  20. tiny-emitter 源码解析

热门文章

  1. Linux服务器与windows本地之间的数据同步
  2. 使用diskpart命令修复U盘分区
  3. pragma comment的使用 pragma预处理指令详解
  4. 关于激励函数的一些思考
  5. 利用matlab对xml文件进行批量处理
  6. DW Question Answer Pro 1.3.4 DWQA问答系统插件
  7. [C++调试笔记]网格划分grid_pic.cpp
  8. axios 登录后设置header_axios如何利用promise无痛刷新token
  9. 3DSlicer15:Scripted Module
  10. Qt修炼手册9_Ui名字空间及setupUi()原理解读