HUNNU--湖师大--11409--Skill

Skill

Yasser is an Egyptian coach; he will be organizing a training camp in Jordan. At the end of camp, 

Yasser was quiet amazed that the participants solved all of the hard problems he had prepared; so he 
decided to give them one last challenge:
Print the number of integers having N digits where the digits form a non decreasing sequence.
Input Specification
Input will start with T <= 100 number of test cases. Each test case consists of a single line having 
integer N where 1 <= N <= 100000.
Output Specification
For each test case print on a separate line the number of valid sequences modulo 1000000007.
Sample Input
3
2
3

4


Sample Output
55
220

715

   这题是想要暴力的弟弟们妹妹们,放弃治疗吧,看到没?输出都对10亿取模了,好吧,不啰嗦了,这个小题的搞法呢是一位一位去考虑,当然就是传说中的“打表”了,你想啊,题目要求的是非递减,所以我只要从少一位的里面所有数考虑,比如12,我要加一位(只说加最前面,其实一样的),要满足条件就只能是112和012了,快要搞不清了,直接上代码再喷口水吧

#include <iostream>
#define mod 1000000007
using namespace std;
int main (void)
{
    int t,n,i,j,k,l,xx[10]={1,1,1,1,1,1,1,1,1,1},d[100001]={0,10};  //xx里面是最高位数字能有的数字数量,d就是要打的表
    for(i=2;i<100001;i++)
    {
        for(j=9;j>=0;j--)  //从大的向小的找,像我要加一位,当前最高位数字是9,那么我可以加9、8、7、6、5、4、3、2、1、0
        for(k=j-1;k>=0;k--)  //
当然本身xx[j]就是保存了数据的,所以直接从j-1开始加
        xx[j]=(xx[j]+xx[k])%mod;  //要取模
        for(j=0;j<10;j++)  //把当前位数的结果装进表中
        d[i]=(d[i]+xx[j])%mod;
    }
    cin>>t;
    while(t--&&cin>>n)
    {
        cout<<d[n]<<endl;
    }
    return 0;
}

   一两句话说不清楚,那就举例子好一点

最高位数字  0  1  2  3  4  5  6  7  8  9

1位:           1  1  1  1  1  1  1  1  1  1    //因为一位数的时候满足条件的只有0,1,2,3,4,5,6,7,8,9,每个数字在最高位只有一次

2位:           1  2  3  4  5  6  7  8  9  10  //两位数我0开头的就是00,1开头的是10,11,2开头是20,21,22.....这下有头绪了没?--!2位的时候我只要看1位的时候最高位数字的个数,然后哪些是可以加上去的我就加上去,怎么样?是不是蛮哈皮的搞法?亲~~

 

转载于:https://www.cnblogs.com/suncoolcat/p/3358221.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
if __name__ == '__main__': # -------------Adjustable global parameters---------- n=512 # pixel number m=10 # number of time phases angle = 5 # #sample points = 360/angle on the boundary numOfAngles = int(180/angle) numOfContourPts = int(360/angle) labelID = 1 # 勾画的RS文件中第几个轮廓为GTV # path of the input data folder = 'E:\\MedData\\4DCT-202305\\' #patient = '0007921948' # 缺少时间信息 patient = '0000726380' # 病人的编号 # 呼吸曲线数据文件 vxpPath = folder+patient+'\\0000726380\\0000726380_20230420_143723.vxp' # Save the generated figures to the latex file path figPath = "D:\\HUNNU\\Research\\DMD\\4D-CT\\latex-DMD插值\\modify202305\\figure\\" # -------------Auto generated global parameters---------- # 每个dicom文件包含多少横截面 name = os.listdir(folder+patient+'\\0') cuts = [] for i in range(len(name)): if 'CT' in name[i][0:2]: cuts.append(i+1) cuts = np.array(cuts) # phase name times = np.linspace(0,90,10) # image pixel coordinate nums = np.linspace(0,n-1,n) x,y = np.meshgrid(nums,nums) # 输出dicom头文件信息 filename = folder+patient+'\\0\\CT.{}'.format(patient)+'.Image 1.dcm' print('CT dicom file information:') info = loadFileInformation(filename) # 像素之间的间距,包括列间距和行间距,单位mm SliceThickness = info['SliceThickness'] # Z轴的扫描分辨率,单位mm pixelSpace = info['pixelSpace'] # 一个像素所占的实际体积 pixelVol = float(pixelSpace[0])*float(pixelSpace[0])*float(SliceThickness) print('sliceThickness=',SliceThickness,' pixelSpace=',pixelSpace)
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值