bjfu1281
思路挺简单的,但因为需要处理大数,所以就比较耗代码了。
/*
* 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的更多相关文章
随机推荐
- JLink and JTAG等接口简介
1.JTAG JTAG用的计算机的并口,JTAG也是一种国际标准测试协议(IEEE 1149.1兼容),主要用于芯片内部测试.现在多数的高级器件都支持JTAG协议,如DSP.FPGA器件等. 标准的J ...
- 本博客不再更新,欢迎访问本人托管在GitHub上的博客:www.wshunli.com
本博客不再更新. 欢迎访问本人托管在GitHub上的博客:www.wshunli.com
- Spring AOP 创建增强类
AOP联盟为增强定义了org.aopalliance.aop.Advice接口,Spring支持5种类型的增强: 1)前置增强:org.springframework.aop.BeforeAd ...
- Java 类加载器(转)
java虚拟机中可以安装多个类加载,系统默认三个主要类加载器,每个类负责加载特定位置的类:BootStrap(内嵌在java虚拟机中由C++编写),ExtClassLoader,AppClassLoa ...
- 卷积神经网络CNN全面解析
卷积神经网络(CNN)概述 从多层感知器(MLP)说起 感知器 多层感知器 输入层-隐层 隐层-输出层 Back Propagation 存在的问题 从MLP到CNN CNN的前世今生 CNN的预测过 ...
- Linux守护进程详解(init.d和xinetd) [转]
一 Linux守护进程 Linux 服务器在启动时需要启动很多系统服务,它们向本地和网络用户提供了Linux的系统功能接口,直接面向应用程序和用户.提供这些服务的程序是由运行在后台 的守护进程来执行的 ...
- poj - 2431 Expedition (优先队列)
http://poj.org/problem?id=2431 你需要驾驶一辆卡车做一次长途旅行,但是卡车每走一单位就会消耗掉一单位的油,如果没有油就走不了,为了修复卡车,卡车需要被开到距离最近的城镇, ...
- eclipse ADT下载地址
adt not vpn https://dl.google.com/android/eclipse/ 或 https://dl-ssl.google.com/android/eclipse/ andr ...
- C# 为WebBrowser设置代理,打开网页
WebBrowser控件是基于IE浏览器的,所以它的内核功能是依赖于IE的,相信做.NET的人都知道. 今天的主题,和上一篇文章应该是差不多的,都是通过代理来实现功能的. 请看下面的代码: //1.定 ...
- 标准模板库(STL)学习探究之stack
标准模板库(STL)学习探究之stack queue priority_queue list map/multimap dequeue string