http://acm.hdu.edu.cn/showproblem.php?pid=4956

首先给出一个范围 [l, r],问能否从中找到一个数证明 Hanamichi’s solution 的解法(对于某个数 X,偶数位的数字之和 -
 奇数位的数字之和  = 3  而且 这个 X 满足 X mod 11 = 3 )是错的。也就是在范围里寻找是否存在不能同时满足:①偶数位的数字之和 -  奇数位的数字之和  = 3; ②X mod 11 = 3;

暴力

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include<set>
#include <iostream>
#include <algorithm>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define clr0(x) memset(x,0,sizeof(x))
typedef long long LL;
bool sum(LL n)
{
int ans = 0,cnt = 0;
while(n){
if(cnt&1)
ans -= n%10;
else
ans += n%10;
n/=10;
cnt++;
}
//cout<<ans<<endl;
if(ans == 3)
return true;
return false;
}
int main() {
//cout<<sum(102);
int _;
RD(_);
LL l,r;
while(_--){
scanf("%I64d%I64d",&l,&r);
LL ll = l/11,rr = (r+8)/11,ans;
ans = 11*ll+3;
while(ans<l)
ans+=11;
while(sum(ans)){
ans+=11;
if(ans > r)
break;
}
if(ans>r){
puts("-1");
}
else
printf("%I64d\n",ans);
}
return 0;
}

hdu 4956的更多相关文章

  1. hdu 4956 Poor Hanamichi BestCoder Round #5(数学题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4956 Poor Hanamichi Time Limit: 2000/1000 MS (Java/Ot ...

  2. BestCoder5 1001 Poor Hanamichi(hdu 4956) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4956(它放在题库后面的格式有一点点问题啦,所以就把它粘下来,方便读者观看) 题目意思:给出一个范围 [ ...

  3. [BestCoder Round #5] hdu 4956 Poor Hanamichi (数学题)

    Poor Hanamichi Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  4. hdu 4956(思路题)

    Poor Hanamichi Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  5. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  6. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  7. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  8. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  9. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

随机推荐

  1. The requested resource (/) is not available解决办法

    The requested resource (/) is not available HTTP Status 404(The requested resource is not available) ...

  2. cat 生成文件 运行脚本

    nohup python -u day_std_cid_list_data_done.py >eee1.log 2>&1 & 后台运行python脚本 hadoop fs ...

  3. php ip2long 负数问题

    官方网站: Note: 因为PHP的 integer 类型是有符号,并且有许多的IP地址讲导致在32位系统的情况下为负数, 你需要使用 "%u" 进行转换通过 sprintf()  ...

  4. RecycleView实现侧滑删除item

    对于列表空间的侧滑操作,网上有很多开源的空间可以使用,Google在它的新控件RecycleView中增加了侧滑的API,完全遵循Material Design设计规范,下面看看效果演示: 下面看看介 ...

  5. 64位windows+32位JDK8+32位eclipse是可以的

  6. Frog and Portal(思维好题)

    Frog and Portal https://hihocoder.com/problemset/problem/1873 时间限制:1000ms 单点时限:1000ms 内存限制:512MB 描述 ...

  7. 兼容多浏览器的html圆角特效

    前言:通常情况下,我们使用css3样式中的border-radius实现圆角效果,但是这种方法IE8.0以下版本浏览器是不支持的. 但是目前使用IE8.0的用户还比较多,Windows XP系统最高支 ...

  8. C/C++堆、栈及静态数据区详解

    转自:https://www.cnblogs.com/hanyonglu/archive/2011/04/12/2014212.html  做略微修改 C/C++堆.栈及静态数据区详解   本文介绍C ...

  9. 查看端口号根据pid号找到相关占用端口应用

    查看端口号根据pid号找到相关占用端口应用   8080 端口被占用不知道被哪个应用软件占用,下面我来教你查出那个该死的应用 方法/步骤   1 首先用netstat 找到端口对应的pid号,找到之后 ...

  10. [leetcode]426. Convert Binary Search Tree to Sorted Doubly Linked List二叉搜索树转有序双向链表

    Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers ...