思路挺简单的,但因为需要处理大数,所以就比较耗代码了。

/*
* Author : ben
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <functional>
#include <numeric>
#include <cctype>
using namespace std; //比较两个数s1和s2的大小,当s1<s2时返回真
bool lessthan(const char* s1, const char* s2, int len) {
for (int i = ; i < len; i++) {
if (s1[i] < s2[i]) {
return true;
} else if (s1[i] > s2[i]) {
return false;
}
}
return false;
} //检测是否栅栏数
bool judge(const char* ss, int len) {
if (len < || len % == ) {
return false;
}
int d = len / ;
for (int i = ; i < d; i++) {
if (ss[i] != '' || ss[len - i - ] != '') {
return false;
}
}
return true;
} int lowercount(const char* ss, int len) {
if (len < ) {
return ;
}
if (len % == ) {
return (len / - ) * ;
}
if (judge(ss, len)) {
return (len / - ) * + ss[len / ] - '';
}
char str[];
memset(str, '', len);
str[len] = ;
str[len / ] = '';
if (lessthan(ss, str, len)) {
return (len / - ) * ;
} else {
return (len / ) * ;
}
} int main() {
// freopen("data.in", "r", stdin);
char a[], b[];
int T, lena, lenb;
scanf("%d", &T);
for (int t = ; t <= T; t++) {
scanf(" %s %s", a, b);
lena = strlen(a);
lenb = strlen(b);
int ans = lowercount(b, lenb) - lowercount(a, lena);
if (judge(b, lenb)) {
ans++;
}
printf("%d\n", ans);
}
return ;
}

bjfu1281的更多相关文章

随机推荐

  1. C# windows 服务编写及安装

      最近项目中用到window服务程序,以前没接触过,比较陌生,花了两天的时间学习了下,写了个简单的服务,但在制作安装程序的时候,参照网上很多资料,却都制作不成功,可能是开发环境或项目配置的不同,这里 ...

  2. 【查找结构3】平衡二叉查找树 [AVL]

    在上一个专题中,我们在谈论二叉查找树的效率的时候.不同结构的二叉查找树,查找效率有很大的不同(单支树结构的查找效率退化成了顺序查找).如何解决这个问题呢?关键在于如何最大限度的减小树的深度.正是基于这 ...

  3. 开启MySQL慢查询日志

    1.修改my.cnf或my.ini 1).linux----------------------------------- /etc/my.cnf  文件 [mysqld] long_query_ti ...

  4. python 调用 C++ code

    本文以实例code讲解python 调用 C++的方法. 1. 如果没有参数传递从python传递至C++,python调用C++的最简单方法是将函数声明为C可用函数,然后作为C code被pytho ...

  5. SSO之CAS单点登录详细搭建教程

    本教程是我个人编写,花费几个小时的时间,给需要学习的人员学习使用,希望能帮助到你们. [环境说明]:本文演示过程在同一个机器上的(也可以在三台实体机器或者三个的虚拟机上),环境如下: windows7 ...

  6. Win7 系统引导盘(C盘)空间越来越小怎么办?

    Win7的系统引导盘用着用着会越来越小.怎么办呢?我以前在网上查过资料,说是找个工具加大C盘.我加了,从原来的20G加到现在的35G.用了一段时间后,空间又只剩几百M了.难道又要加?? 后来,在网上找 ...

  7. Lucene学习笔记(更新)

    1.Lucene学习笔记 http://www.cnblogs.com/hanganglin/articles/3453415.html    

  8. Android模拟器使用教程

    Using the Emulator In this document Overview Android Virtual Devices and the Emulator Starting and S ...

  9. BZOJ 1009 GT考试(ac自动机+矩阵DP)

    题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=1009 题意:给定一个长度为m的串s.有多少种长度为n的串不包含s? 思路:(1)将s插入 ...

  10. leetcode:Plus One

    Given a non-negative number represented as an array of digits, plus one to the number. The digits ar ...