Content

给定一个数 \(n\),求出 \(n\) 最大的可以表示成 \((2^k-1)\cdot2^{k-1}\) 形式的因数 \(x\)。

数据范围:\(1\leqslant n\leqslant 10^5\)。

Solution

数据范围很小,所以我们先考虑将 \(10^5\) 以内的能够表示成 \((2^k-1)\cdot2^{k-1}\) 形式的数全部通过打表生成出来。而且打完以后,我们发现,事实上满足这个条件的数在 \(10^5\) 以内只有 \(8\) 个:\(1,6,28,120,496,2016,8128,32640\)。

然后输入完 \(n\),就直接从 \(n\) 开始往 \(1\) 直接枚举,一旦找出了可以表示成 \((2^k-1)\cdot2^{k-1}\) 的因数就直接输出即可。

Code

int num[17], n, cnt, vis[200007];

int main() {
while(num[cnt] <= 100000) ++cnt, num[cnt] = (1 << (2 * cnt - 1)) - (1 << (cnt - 1));
F(int, i, 1, cnt) vis[num[i]] = 1;
n = Rint;
R(int, i, n, 1) if(vis[i] && !(n % i)) return write(i), 0;
return 0;
}

CF893B Beautiful Divisors 题解的更多相关文章

  1. codeforces 893B Beautiful Divisors 打表

    893B Beautiful Divisors 思路: 打表 代码: #include <bits/stdc++.h> using namespace std; #define _for( ...

  2. Educational Codeforces Round 33 (Rated for Div. 2) B. Beautiful Divisors【进制思维/打表】

    B. Beautiful Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  3. CF55D Beautiful numbers 题解

    题目 Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer n ...

  4. 【SP26073】DIVCNT1 - Counting Divisors 题解

    题目描述 定义 \(d(n)\) 为 \(n\) 的正因数的个数,比如 \(d(2) = 2, d(6) = 4\). 令 $ S_1(n) = \sum_{i=1}^n d(i) $ 给定 \(n\ ...

  5. 【Educational Codeforces Round 33 B】Beautiful Divisors

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 把所有的那些数字打表出来. 逆序枚举就好 [代码] /* 1.Shoud it use long long ? 2.Have you ...

  6. CF1265B Beautiful Numbers 题解

    Content 给定一个 \(1\sim n\) 的排列,请求出对于 \(1\leqslant m\leqslant n\),是否存在一个区间满足这个区间是一个 \(1\sim m\) 的排列. 数据 ...

  7. UVA294 约数 Divisors 题解

    Content 给定 \(n\) 个区间 \([l,r]\),求出每个区间内约数个数最大的数. 数据范围:\(1\leqslant l<r\leqslant 10^{10}\),\(r-l\le ...

  8. Codeforces Round #604 (Div. 2) E. Beautiful Mirrors 题解 组合数学

    题目链接:https://codeforces.com/contest/1265/problem/E 题目大意: 有 \(n\) 个步骤,第 \(i\) 个步骤成功的概率是 \(P_i\) ,每一步只 ...

  9. HDU5179 beautiful number 题解 数位DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5179 题目大意: 给你一个数 \(A = a_1a_2 \cdots a_n\) ,我们称 \(A\) ...

随机推荐

  1. pycharm两个交互模式

  2. lua_newthread的真正意义

    lua_newthread 这个接口,存在误导性,很多人第一次试图用它来解决多线程问题时,都会入坑. 实际上,这个接口真正的用法,是给那些在lua更底层的某些行为(通常是递归)导致了lua的栈溢出而准 ...

  3. 关于写SpringBoot+Mybatisplus+Shiro项目的经验分享四:部署到阿里云

    框架: SpringBoot+Mybatisplus+Shiro 简单介绍:关于写SpringBoot+Mybatisplus+Shiro项目的经验分享一:简单介绍 阿里云开放必要端口,mysql与t ...

  4. Tomcat类加载机制和JAVA类加载机制的比较

    图解Tomcat类加载机制    说到本篇的tomcat类加载机制,不得不说翻译学习tomcat的初衷.    之前实习的时候学习javaMelody的源码,但是它是一个Maven的项目,与我们自己的 ...

  5. act.四级

    act的词源是do, 干着或干了的事情也可以叫act.action: doing sth; act: n. action, v. do; activity: busy, energetic, or占据 ...

  6. 3.5 Rust Generic Types, Traits, and Lifetimes

    Every programming language has tools for effectively handling the duplication of concepts. In Rust, ...

  7. Default arguments and virtual function

    Predict the output of following C++ program. 1 #include <iostream> 2 using namespace std; 3 4 ...

  8. zabbix之微信报警

    #:先在企业微信注册一个企业微信号 #:注册好之后,进入微信 #:测试一下 #:获取access_token #:开始获取 #:获取 #:在server端安装pip root@ubuntu:~# ap ...

  9. shell脚本实现openss自建CA和证书申请

    #!/bin/bash # #******************************************************************** #Author: Ma Xue ...

  10. Spring Cloud 和dubbo

    一.SpringCloud微服务技术简介 Spring Cloud 作为Java 语言的微服务框架,它依赖于Spring Boot,有快速开发.持续交付和容易部署等特点.Spring Cloud 的组 ...