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. scala spark rdd转数据框

    1. http://blog.csdn.net/lw_ghy/article/details/51480358

  2. 根据条件决定是否为input设置只读属性

    代码如下: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <tit ...

  3. /Library,/System/Library,~/Library

      /System/library是系统级,/ Library下面面向全部用户,~/Library 限于当前用户 一般来说,很少碰/ Library,都是用到/System/library和~/lib ...

  4. DOS批处理前言

    -----------made by siwuxie095 1.批处理(Batch):望文知义,对某对象进行批量处理,实际上是一种脚本 2.DOS(Disk Operating System-磁盘操作 ...

  5. C++,坑...

    如果使用const全局变量,记得声明处的引用处都加extern. uint32_t等,t代表是typedef的,在stdint.h头文件里,C99后引入,记得先测试再用. accept函数的参数,记得 ...

  6. 验证二叉查找树 · Validate Binary Search Tree

    [抄题]: [思维问题]: 不知道要定义resultType, 其实用仔细分析判断条件就行了:是否是bst+最大最小值 类似于平衡二叉树:是否平衡+左右的高度差 [一句话思路]: [输入量]:空: 正 ...

  7. 每天学一点儿HTML5的新标签

    sections部分 (http://www.w3.org/TR/html5/sections.html) 标签:article article标签用来表示页面中一段完整的可以自我包含的片段,具有可重 ...

  8. php的opcode缓存原理

    opcode是什么? 它是一种PHP脚本编译后的中间语言,类似java的字节码.   PHP代码执行(Zend引擎)的步骤如下: 1.Scanning(Lexing) ,将PHP代码转换为语言片段(T ...

  9. 利用委托机制处理.NET中的异常

    WinForm代码 private void button1_Click(object sender, EventArgs e) { try { Convert.ToInt32("abcd& ...

  10. Codeforces C. NP-Hard Problem 搜索

    C. NP-Hard Problem time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...