失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > Problem 2 西行寺幽幽子(spring.cpp/c/pas)

Problem 2 西行寺幽幽子(spring.cpp/c/pas)

时间:2022-03-19 15:04:09

相关推荐

Problem 2  西行寺幽幽子(spring.cpp/c/pas)

Problem 2 西行寺幽幽子(spring.cpp/c/pas)

题目描述 在幻想乡,西行寺幽幽子是以贪吃闻名的亡灵。不过幽幽子可不是只会吃,至少她还管理着

亡灵界。话说在幽幽子居住的白玉楼有一颗常年不开花的樱树——西行妖。幽幽子决定去收集

人间的春度,聚集起来让西行妖开花。很快,作为幽幽子家园艺师的魂魄妖梦收集到了 M 个

单位的春度。并且在这段时间里,幽幽子计算出要让西行妖开出一朵花需要 N 个单位的春度。

现在幽幽子想要知道,使用所有的春度,能够让西行妖开出多少朵花。

输入格式 第 1 行:一个正整数 M

第 2 行:一个正整数 N

N,M 的位数不超过L,L 的范围在题目后面给出

输出格式 第 1 行:一个整数ans,表示能开出花的朵数

输入样例 73861758

12471

输出样例 5922

数据范围 对于 60%的数据:L <= 2,000 且 ans <= 2,000

对于 100%的数据:L <= 20,000 且 ans <= 2,000,000,000

const md=10000;max=2000000000;type arr=array[0..20000] of int64;var n,m,now:arr;s:ansistring;i,j,k,sum:longint;l,r,mid:int64;//fuck procedure change(var a:arr);var i,len:longint;s0:string;beginlen:=length(s);{for i:=1 to len doa[i]:=ord(s[len-i+1])-ord('0');a[0]:=len;}while length(s)>=4 dobegins0:=copy(s,length(s)-3,4);inc(a[0]); val(s0,a[a[0]]);delete(s,length(s)-3,4);end;if s<>'' thenbegininc(a[0]); val(s,a[a[0]]);end;end;procedure cheng;var i:longint;beginnow:=n; now[1]:=now[1]*mid;for i:=2 to now[0] dobeginnow[i]:=now[i]*mid+now[i-1] div md;now[i-1]:=now[i-1] mod md;end;while now[now[0]]>md dobegininc(now[0]); now[now[0]]:=now[now[0]-1] div md;now[now[0]-1]:=now[now[0]-1] mod md;end;end;function ok:boolean;var i:longint;begincheng;if now[0]>m[0] then exit(false);if m[0]>now[0] then exit(true);for i:=now[0] downto 1 doif now[i]>m[i] then exit(false)else if now[i]<m[i] then exit(true);exit(true);end;beginassign(input,'spring.in'); assign(output,'spring.out');reset(input); rewrite(output);readln(s); change(m);readln(s); change(n);l:=0; r:=max;{mid:=5984; cheng;}while r-l>1 dobeginmid:=(r+l) div 2;if ok then l:=mid else r:=mid;//fuckend;writeln(l);close(input); close(output);end.

如果觉得《Problem 2 西行寺幽幽子(spring.cpp/c/pas)》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。