编程介的小学生 2019-05-01 00:11 采纳率: 20.5%
浏览 127

图的步数的一个计算的问题,怎么利用C语言的程序的设计的思想去实现的?

Problem Description
In a directed graph which has N points and M edges,points are labled from 1 to n.At first I am at point u,at each step I will choose an output edge of the current point at uniform random,for every point Z,please output the possibility of reaching the point Z,moving exactly K steps.

Input
the first line contains two positive intergesN,M,means the number of points and edges.

next M lines,contains two positive intergersX,Y,means an directed edge from X to Y.

next line there is an integer Q,means the number of queries.

next Q lines,each line contains two integers u,K,means the first point and number of the steps.

N≤50,M≤1000,Q≤20,u≤N,K≤109.

Every point have at least one output edge.

Output
Q lines,each line contains N numbers,the i-th number means the possibility of reaching point i from u,moving exactly K steps.

In consideration of the precision error,we make some analyses,finding the answer can be represented as the form like XY,you only need to output X×Y109+5 mod (109+7).

You need to output an extra space at the end of the line,or you will get PE.

Sample Input
3 2
1 2
1 3
1
1 1

Sample Output
0 500000004 500000004

I am now at point $1$,by one move,with a possibity of $\frac{1}{2}$ of reaching point 2,with a possibity of $\frac{1}{2}$ of reaching point 3,so we need to output 0 0.5 0.5,but as what is said above,we need to output$1*2^{10^9+5}~mod~{10^9+7}=500000004$.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥65 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥200 uniapp长期运行卡死问题解决
    • ¥15 latex怎么处理论文引理引用参考文献
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?