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的更多相关文章
随机推荐
- Phalanx--hdu2859(dp 最大对称子图)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2859 题意就是给你一个n*n的字符矩阵,从中选出一个最大的子矩阵(m*m)满足关于斜对角线(左下角到右 ...
- MyBatis主键返回
在使用MyBatis做持久层时,insert语句默认是不返回记录的主键值,而是返回插入的记录条数:如果业务层需要得到记录的主键时,可以通过配置的方式来完成这个功能. 比如在表的关联关系中,将数据插入主 ...
- skip-name-resolv
skip-name-resolve skip-name-resolve 简单解释 MySQL server received a request from you to allow you to co ...
- 忘记导入struts2-xxx-plugin-x.x.x.jar导致服务器启动报Unable to load configuration.Caused by: Parent package is not defined: xxx-default
今天做的一个Struts2+MyFaces(JSF)+Spring的应用,为了使用JSF,我的struts.xml中使用了如下代码 <package name="jsf" e ...
- asp.net mvc4使用百度ueditor编辑器
原文 http://www.cnblogs.com/flykai/p/3285307.html 已测试 相当不错 前言 配置.net mvc4项目使用ueditor编辑器,在配置过程中遇见了好 ...
- iPhone 屏幕上的 Home 键在哪里?(已解决)
「问」:iPhone屏幕上的Home键如何开启? 「答」:在[设置]-[通用]-[辅助功能]-[AssistiveTouch],打开即可.不需要下载什么App. [Settings] - [Gener ...
- 第一篇 ERP是什么?-从道的层面浅谈我的理解
世界上称为ERP软件的软件很多,国外的有SAP,ORACLE,国内的有金蝶,用友,浪潮.这些由不同的厂商开发制作的软件总有其软件适用的场合.这个场合就是企业,而且是市场经济中的企业.个人是不会购买ER ...
- 【转载】两军问题与Paxos算法 & 动画讲解Paxos算法
http://harry.me/blog/2014/12/27/neat-algorithms-paxos/ 这篇文章里面有用JS写的Paxos过程,有助理解.但是没怎么仔细看,没时间. 这篇文章用两 ...
- spring 定时器设置每隔10秒触发
<property name="cronExpression" value="0/10 * * * * ?" />
- mac terminal 命令
mac下显示隐藏文件 显示 defaults write com.apple.finder AppleShowAllFiles -bool true 隐藏 defaults write com.app ...