您的位置:首页 > 其它

2012百度之星初赛第一场

2012-06-02 11:41 239 查看
这个初赛一共有4道题目,我只有出来B题。不过,也没办法,像我这种新手在两个小时内根本不可能做得完。明天还有一场,争取也能做出一道题目。

我的B题答案:

#include <string>
#include <iostream>
#include <math.h>
using namespace std;
int main(){
long int x,a,b;
int n;
cin>>n;
while(n--)
{
cin>>x>>a>>b;
if(x>b)
cout<<0<<endl;
int length1=(int)floor(log10((double)x))+1;
int length2=(int)floor(log10((double)a))+1;
int length3=(int)floor(log10((double)b))+1;
int head1=a/(int)pow(10.0,length1);
int head2=b/(int)pow(10.0,length2);
int end1=a%(int)pow(10.0,length1);
int end2=b%(int)pow(10.0,length2);
int cha=head2-head1;
if(end1<=x&&end2>=end1)
cha++;
cout<<cha<<endl;
}
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: