思路:

首先,inedible tails 的个数最多为C(18+9,9)个(用隔板法),所以我们暴力出所有的 inedible tails,然后检查一下在[L, R]这段区间是否存在这个inedible tails

检查的时候用了和数位dp差不多的方法,设一个下界和上界,只要之前的既没有达到上界也没有达到下界,后面就可以随便填了,说明存在

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head int l[], r[], f[], ans = , cnt = ;
bool check(int pos, bool Llimit, bool Rlimit) {
if(!Llimit && !Rlimit) return true;
if(pos == ) return true;
int down = Llimit ? l[pos] : ;
int up = Rlimit ? r[pos] : ;
for (int i = down; i <= up; i++) {
if(f[i]) {
f[i]--;
bool flag = check(pos-, Llimit&&i==l[pos], Rlimit&&i==r[pos]);
f[i]++;
if(flag) return true; }
}
return false;
}
void dfs(int pos, int res) {
if(pos == ) {
f[pos] = res;
if(check(cnt, , )) ans++;
return ;
}
for (int i = ; i <= res; i++) {
f[pos] = i;
dfs(pos+, res - i);
}
}
int solve(LL L, LL R) {
cnt = ;
while(L) {
l[++cnt] = L%;
L /= ;
} cnt = ;
while(R) {
r[++cnt] = R%;
R /= ;
}
ans = ;
dfs(, cnt);
return ans;
}
int main() {
LL L, R;
scanf("%lld %lld", &L, &R);
printf("%d\n", solve(L, R));
return ;
}

Codeforces 833 C - Ever-Hungry Krakozyabra的更多相关文章

  1. Educational Codeforces Round 34 A. Hungry Student Problem【枚举】

    A. Hungry Student Problem time limit per test 1 second memory limit per test 256 megabytes input sta ...

  2. Codeforces Round #833 (Div. 2)补题

    Codeforces Round #833 (Div. 2) D. ConstructOR 知识点:高位和对低位无影响 一开始以为和广州的M一样,是数位dp,后来发现只要找到一个就行 果然无论什么时候 ...

  3. codeforces hungry sequence 水题

    题目链接:http://codeforces.com/problemset/problem/327/B 这道题目虽然超级简单,但是当初我还真的没有想出来做法,囧,看完别人的代码恍然大悟. #inclu ...

  4. Codeforces Round #191 (Div. 2) B. Hungry Sequence(素数筛选法)

    . Hungry Sequence time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  5. codeforces 327 B. Hungry Sequence

    题目链接 题目就是让你输出n个数的序列,要保证该序列是递增的,并且第i个数的前面不能保护它的约数,我直接先对前100000的素数打表,然后输出前n个,so easy. //cf 191 B #incl ...

  6. Codeforces Round #833 (Div. 2) A-D.md

    比赛链接 A 题解 知识点:数学. 注意到 \(n\) 为奇数时,不考虑连续性,一共有 \(\lceil \frac{n}{2} \rceil ^2\) 个格子,接下来证明一定能凑成方块. 从下往上从 ...

  7. Codeforces Round #342 (Div. 2) A - Guest From the Past 数学

    A. Guest From the Past 题目连接: http://www.codeforces.com/contest/625/problem/A Description Kolya Geras ...

  8. Codeforces Round #325 (Div. 2) B. Laurenty and Shop 前缀和

    B. Laurenty and Shop Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/p ...

  9. Codeforces 833E Caramel Clouds

    E. Caramel Clouds time limit per test:3 seconds memory limit per test:256 megabytes input:standard i ...

随机推荐

  1. Python2的一些问题及解决办法

    1. 无法注释中文的解决办法 # -*- coding:utf8 -*- # 添加这一行就行了 from django.contrib import admin from myapp.models i ...

  2. sync—WaitGroup

    用途:阻塞主线程的执行,直到所有的goroutine执行完成 WaitGroup总共有三个方法:Add(delta int),Done(),Wait().简单的说一下这三个方法的作用. Add:添加或 ...

  3. Elasticsearch.Net使用(一)【入门篇】

    http://blog.csdn.net/wulex/article/details/52138564 加数据 //在调用下面的index方法的时候,如果没有指定使用哪个index,ElasticSe ...

  4. intel FPGA使用

    https://www.altera.com/documentation/swn1503506366945.html https://files.cnblogs.com/files/shaohef/o ...

  5. android之发送Get或Post请求至服务器接口

    import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.IOException; imp ...

  6. android 导出apk

    一个困扰了几个月的问题在今天得以解决,运动益智可能有点过,能让一个人思路清晰倒是真! 问题描述:本地调试运行及不加密导出apk运行正常,当加密生成apk安装后,从接口返回的数据总是空.尝试过各种配置, ...

  7. jQuery中清空元素.empty()和.html(''),两种方法的对比

    jQuery 中有 .empty() 和 .html() 两种方式,都能够清空所选父元素中的所有子元素.但是这两者清空元素的方式上,有着很大的区别: 1.empty() jQuery对象.empty( ...

  8. TensorFlow模型保存和加载方法

    TensorFlow模型保存和加载方法 模型保存 import tensorflow as tf w1 = tf.Variable(tf.constant(2.0, shape=[1]), name= ...

  9. topcoder srm 696 div1 -3

    1.给定一个50个节点的无向图,有$m$条边.现在以任意一种序列对每个节点染色.染当前节点的代价为染色完当前节点后满足两个端点都被染色的边的数量.求最小的染色代价.$m \leq 20$ 思路:一个直 ...

  10. uniGUI试用笔记(六)

    uniGUI提供了一个文件上传控件TUniFileUpload,进行数据的导入就变得比较容易.首先将TUniFileUpload控件放置在窗体上,按下导入按钮后,执行TUniFileUpload的文件 ...