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. 通过正则获取url参数

    1.通过正则来获取url地址栏的参数: ---------------------------我是分割线-------------------------------- var reg1=/([^?& ...

  2. KMP入门(匹配)

    Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M ...

  3. makefile-0711-168 SEVERE ERROR: Input file:

    ld: 0711-168 SEVERE ERROR: Input file: /cicm/commlib/include        Input files must be regular file ...

  4. 模板方法模式(Template Pattern)

    模板方法模式:在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中.模板方法使得子类可以在不改变算法的结构下,重新定义算法中的某些步骤. 这个模式是用来创建一个算法模板.模板就是一个方法.更具体地 ...

  5. 把DataSet转换成JSON

    /// <summary> /// dataTable转换成Json格式 /// </summary> /// <param name="dt"> ...

  6. 微调Win8.1这台电脑

    从前有个笑话:一位朋友在办公室受到领导教育:“我说小王同志啊,虽然这电脑是你打了报告组织上买给你用的,可是你也不好这么狂妄嘛...”可怜的他只好把图标的名字改为“大家的电脑”. 想必大家已经知道这个笑 ...

  7. ECSHOP 订单状态 记录

    记录订单状态 order_status /* 订单状态 */ define(‘OS_UNCONFIRMED’,            0); // 未确认 define(‘OS_CONFIRMED’, ...

  8. Ms SQLServer中的Union和Union All的使用方法和区别

    Ms SQLServer中的Union和Union All的使用方法和区别 SQL UNION 操作符 UNION 操作符用于合并两个或多个 SELECT 语句的结果集. 请注意,UNION 内部的 ...

  9. CGAL 介绍

    CGAL组织 内核 数值健壮 基础库 扩展性 2.4 命名约定 Naming In order to make it easier to remember what kind of entity a ...

  10. Python数据库连接池实例——PooledDB

    不用连接池的MySQL连接方法 import MySQLdbconn= MySQLdb.connect(host='localhost',user='root',passwd='pwd',db='my ...