codeforces 893B Beautiful Divisors 打表

893B Beautiful Divisors

思路:

打表

代码:

#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=(a); i<(b); ++i)
#define _rep(i,a,b) for(int i=(a); i<=(b); ++i)
int a[8]={1,6,28,120,496,2016,8128,32640};
int main() {
    int n;
    scanf("%d",&n);
    for(int i=7; i>=0; --i) {
        if(n%a[i]==0) {
            printf("%d\n", a[i]);
            return 0;
        }
    }
    return 0;
}
时间: 2024-08-30 02:46:11

codeforces 893B Beautiful Divisors 打表的相关文章

CodeForces - 893B Beautiful Divisors

题目链接 CodeForces - 893B time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautifu

[2016-03-08][651][codeforces][B][Beautiful Paintings]

[2016-03-08][651][[codeforces]][B][Beautiful Paintings] 题目编号:CF 651 B 题目大意:画展有n个画,每个画beauty值已知,客人每经过一个比之前一个画更美的,客人会变得beauty,重新安排画的顺序,求客人开心时间的最大值 输入:n 和每个话的beauty 输出:时间 分析: 如果beauty为a的画,数量为 k,那么beaty小于或者大于a的k个,总能安排让客人开心,所以,除了数量k最大的那个beauty之外,每个beauty总

Codeforces 55D Beautiful Number

Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. Input The first line of the input contains the number of cases t (1 ≤ t ≤ 10). Each of the next t lines contains two

看个人思路吧,清晰的话就简单 CodeForces 271A - Beautiful Year

It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits. Now you are suggested to solve the following problem: given a year number, find the minim

CodeForces 55D Beautiful numbers 数位DP+数学

题意大概是,判断一个正整数区间内有多少个整数能被它自身的每一个非零的数字整除. 因为每一个位置上的整数集s = {0,1,2,3,4,5,6,7,8,9} lcm(s) = 2520 现在有一个整数t是由s中一个或者多个数字构成的,记为abcde,显然t = a*10^4+b*10^3+c*10^2+d*10^1+e 要使得t能被a,b,c,d,e整除,必然有t % lcm(a,b,c,d,e) = 0 因为a,b,c,d,e去重之后一定是s的一个子集,所以lcm(s)一定是lcm(a,b,c,

Codeforces 55D. Beautiful numbers(数位DP,离散化)

Codeforces 55D. Beautiful numbers 题意 求[L,R]区间内有多少个数满足:该数能被其每一位数字都整除(如12,24,15等). 思路 一开始以为是数位DP的水题,觉得只需要记录搜到当前位出现了哪些数字作为状态即可,明显是假算法...感觉这是一道数位DP好题.可以这样思考:一个数要想被其各位数字分别都整除,等价于它被那些数字的LCM整除.因此记录当前位,当前数对(1~9的LCM)取模的结果,当前出现的数字的LCM这三个值作为状态才合理,即dp[pos][sum][

CodeForces 665E Beautiful Subarrays

题目:Beautiful Subarrays 链接:Here 题意:给一个数组,给一个 '完美区间' 的定义:l 到r 区间内的所有数异或和大于等于k,问给定数组有多少完美区间. 思路: 异或运算可以前缀和处理,用w[i]表示i 前面的数异或和,那么w[5]^w[3]就是4.5两数异或的值. 现在我们要开始建字典树了(感觉异或和字典树老扯上关系),我们从前往后一个个地把前缀加入字典树(补齐,高位补0),在w[i]加入字典树前,判断w[i]和前面的哪个前缀可以异或并且值大于等于k.这里要用树形DP

CodeForces 55D Beautiful numbers(数位dp&amp;&amp;离散化)

题目链接:[kuangbin带你飞]专题十五 数位DP A - Beautiful numbers 题意 ps:第一道数位dp,题真好,虽然是参考大牛方法悟过才a,但仍收获不少. 求一个区间内的Beautiful numbers有多少个.Beautiful numbers指:一个数能整除所有组成它的非0数字. 例如15可以被1和5整除,所以15是Beautiful numbers. 思路 Beautiful numbers指:一个数能整除所有组成它的非0数字. 等同于 一个数能整除 所有组成它的

CodeForces 55D Beautiful numbers

Beautiful numbers 题目链接 Description Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just