编程介的小学生 2019-04-02 13:23 采纳率: 20.5%
浏览 132

定义周期二进制字符串的问题,运用C程序的办法的思维解决怎么做

Problem Description
Teacher Mai has an infinite periodic binary string S with index counting from 0. That means S=TTTT..., where T is the period of string S. For example, T="101", then S="101101101101..."

S[l,r] is the sub-string of S. We define f[l,r] is the value when regarding S[l,r] as a binary number.

Please count the number of binary strings T with length k, where T is the period of string S, satisfying the condition: f[l,r]=x (mod p).

The number can be very large, just output the number modulo 1000000007 (10^9+7).

Input
There are multiple test cases, terminated by a line "0 0 0 0 0".

For each test case, there is a line contains five numbers p (2<p<10^18, p is a prime number) ,x (0<=x<p), l, r (0<=l<=r<=10^18) and k (1<=k<=10^18).

Output
For each test case, output one line "Case #k: ans", where k is the case number counting from 1, ans is the number module 10^9+7.

Sample Input
3 0 1 2 1
233 23 2333 23333 23
233 1 1 2 23
0 0 0 0 0

Sample Output
Case #1: 2
Case #2: 36003
Case #3: 2097152

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler