http://acm.hdu.edu.cn/showproblem.php?pid=4669

这题各种错误都来了一遍  预处理一下第一个数作为尾数与相邻前面的数组成的数的余数  然后再与后面的结合求余数

9 6 4 2 8

因为是个环  可以 9 6 4 2 8 9 6 4 2 8 组合 不过 又不能超N

所以先预处理 89 289 4289 64289 的余数 再与后面的组合 删除重复的

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 50005
#define LL __int64
int dp[N][];
int b[N],di[N],pp[N*];
int digit(int x)
{
int i=;
while(x)
{
i++;
x/=;
}
return i;
}
int main()
{
int i,k,n,r,j;
while(scanf("%d%d",&n,&k)!=EOF)
{
for(i = ; i <= n ;i++)
for(j = ; j < k ; j++)
dp[i][j] = ;
for(i = ; i <= n ; i++)
{
scanf("%d",&b[i]);
di[i] = digit(b[i]);
}
pp[] = ;
for(i = ; i <= n* ; i++)
pp[i] = (pp[i-]*)%k;
int pre = ;
b[n+] = b[];
di[n+] = di[];
r = ;
for(i = n+ ; i > ; i--)
{
r = (b[i]*pp[pre]+r)%k;
pre+=di[i];
dp[][r]++;
}
int rr = r;
for(i = ; i <= n ; i++)
{
for(r = ; r < k ; r++)
{
int o = (r*pp[di[i]]+b[i])%k;
dp[i][o] += dp[i-][r];
}
rr = (rr*pp[di[i]]+b[i])%k;
dp[i][rr]--;
dp[i][b[i]%k]++;
rr = (rr-pp[pre]*b[i]+k)%k;
if(rr<) rr+=k;
}
LL maxz=;
for(i = ; i <= n ; i++)
{
maxz+=dp[i][];
}
printf("%I64d\n",maxz);
}
return ;
}

hdu4669Mutiples on a circle的更多相关文章

  1. [翻译svg教程]svg中的circle元素

    svg中的<circle> 元素,是用来绘制圆形的,例如 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink= ...

  2. 设计一个程序,程序中有三个类,Triangle,Lader,Circle。

    //此程序写出三个类,triangle,lader,circle:其中triangle类具有类型为double的a,b,c边以及周长,面积属性, //具有周长,面积以及修改三边的功能,还有判断能否构成 ...

  3. c++作业:Circle

    Circle Github链接

  4. Modified Least Square Method and Ransan Method to Fit Circle from Data

    In OpenCv, it only provide the function fitEllipse to fit Ellipse, but doesn't provide function to f ...

  5. [javascript svg fill stroke stroke-width circle 属性讲解] svg fill stroke stroke-width circle 属性 绘制圆形及引入方式讲解

    <!DOCTYPE html> <html lang='zh-cn'> <head> <title>Insert you title</title ...

  6. (1)编写一个接口ShapePara,要求: 接口中的方法: int getArea():获得图形的面积。int getCircumference():获得图形的周长 (2)编写一个圆类Circle,要求:圆类Circle实现接口ShapePara。 该类包含有成员变量: radius:public 修饰的double类型radius,表示圆的半径。 x:private修饰的double型变量x,

    package com.hanqi.test; //创建接口 public interface ShapePara { //获取面积的方法 double getArea(); //获取周长的方法 do ...

  7. 东大oj-1591 Circle of friends

    题目描述 Nowadays, "Circle of Friends" is a very popular social networking platform in WeChat. ...

  8. svg学习(四)circle

    <circle> 标签 < <?xml version="1.0" standalone="no"?> <!DOCTYPE ...

  9. 后缀数组 --- WOj 1564 Problem 1564 - A - Circle

    Problem 1564 - A - Circle Problem's Link:   http://acm.whu.edu.cn/land/problem/detail?problem_id=156 ...

随机推荐

  1. Gulp实战(二)

    一.配置环境 1.基于NodeJs安装Git,npm,gulp 2.安装各类插件 3.参考文档 http://www.tuicool.com/articles/UbaqyyJ http://www.t ...

  2. VIM 同义词

    vim-online-thesaurus A Vim plugin for looking up words in an online thesaurus, Now thesaurus.com 一.原 ...

  3. MySQL 数据库增量数据恢复案例

    MySQL 数据库增量数据恢复案例 一.场景概述 MySQL数据库每日零点自动全备 某天上午10点,小明莫名其妙地drop了一个数据库 我们需要通过全备的数据文件,以及增量的binlog文件进行数据恢 ...

  4. BootstrapDialog点击空白处禁止关闭

    在乐学一百的项目当中引用到了BootstrapDialog,其中后台发送短信时,为了防止管理员编辑了半天的短息,突然间因为点击某个空白区域导致丢失,所以在此禁用掉点击空白关闭弹出框. 主要属性为: c ...

  5. 不要停留在表面,MVC 3 我们要深入一些

    其实在MVC 中只存在三大组件,Model.View.Controller,其中Model用来作为业务逻辑处理,Controller负责的是Model和View的交互,View负责页面显示. 这是非常 ...

  6. MySQL基础学习之视图

    创建新的视图 CREATE VIEW 视图名  AS SELECT  属性,属性1,属性2  FROM 表名 创建新的视图并指定数据名 CREATE VIEW 视图名(新属性,新属性1,新属性2)   ...

  7. JDBC链接

    //1. MySQL(http://www.mysql.com)mm.mysql-2.0.2-bin.jar  Connection con = null;  Class.forName( " ...

  8. 制作Mac OS X Mavericks 安装U盘

    1. 8G+ U盘一个. 2. App Store 下载Maverics到本地(默认会下载到Applications) 2. 打开Mac OS 磁盘工具(Disk Utility),左侧选中U盘,在右 ...

  9. sum_series() 求一列数的指定个数的数和(5个数字的和)

    #include <stdio.h> #include <stdarg.h> /*用sum_series() 求一列数的指定个数的数和(5个数字的和)*/ double sum ...

  10. Pair Project: Elevator Scheduler [电梯调度算法的实现和测试]:谢勤政-11061197,吴润凡-11061185

    一,关于结对编程 结对编程的优点: 1)在开发层次,结对编程能提供更好的设计质量和代码质量,两人合作能有更强的解决问题的能力. 2)对开发人员自身来说,结对工作能带来更多的信心,高质量的产出能带来更高 ...