码迷,mamicode.com
首页 > 其他好文 > 详细

JLOI 斯迈利的赌注

时间:2015-01-06 22:56:43      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:

直接高精度模拟,加上简单贪心

 1 Program XJOI2263;
 2 type arr=array[0..1000] of longint;
 3 var a,b:arr;
 4     s1,s2:ansistring;
 5     i,j:longint;
 6     sum:int64;
 7 operator *(a:arr;x:longint) c:arr;
 8 var i:longint;
 9 begin
10     fillchar(c,sizeof(c),0);
11     for i:=1 to a[0] do c[i]:=a[i]*x;
12     for i:=1 to a[0] do
13     begin
14         c[i+1]:=c[i+1]+c[i] div 10;
15         c[i]:=c[i] mod 10;
16     end;
17         c[0]:=a[0];
18     while c[c[0]+1]<>0 do
19     begin
20         inc(c[0]);
21         i:=c[0];
22         c[i+1]:=c[i+1]+c[i] div 10;
23         c[i]:=c[i] mod 10;
24     end;
25     exit(c);
26 end;
27 function check(a,b:arr):boolean;
28 begin
29     if a[0]<b[0] then exit(true);
30     if a[0]>b[0] then exit(false);
31     for i:=a[0] downto 1 do
32     begin
33         if a[i]<b[i] then exit(true);
34         if a[i]>b[i] then exit(false);
35     end;
36     exit(true);
37 end;
38 begin
39     readln(s1);
40     readln(s2);
41     a[0]:=length(s1);
42     b[0]:=length(s2);
43     for i:=1 to a[0] do a[i]:=ord(s1[a[0]-i+1])-48;
44     for i:=1 to b[0] do b[i]:=ord(s2[b[0]-i+1])-48;
45     while check(a,b) do
46     begin
47         inc(sum);
48         a:=a*2;
49     end;
50     sum:=sum-1;
51     sum:=sum mod 6;
52     if sum=0 then writeln(0) else
53     begin
54         j:=1;
55         for i:=1 to sum do j:=j*2;
56         writeln(j);
57     end;
58 end.

 

JLOI 斯迈利的赌注

标签:

原文地址:http://www.cnblogs.com/rpSebastian/p/4207137.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!