http://codeforces.com/contest/365/problem/C

构造出的矩阵中的长方形的和等于构成它的长的那些数字的和加上构成它的宽的那些数字的和。 也就是求这个字符串中的两个子字符串的和的乘积等于a的数目。 记录每一个子字符串的和的等于m的数目。然后枚举就可以求出数目。0要单独处理。

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 50000
#define LL __int64
using namespace std; LL a;
char s[maxn];
LL c[maxn];
LL sum[maxn];
LL g[maxn];
LL ans; int main()
{
while(scanf("%I64d",&a)!=EOF)
{
scanf("%s",s);
int k=strlen(s);
for(int i=; i<k; i++)
{
c[i+]=(LL)(s[i]-'');
sum[i+]=sum[i]+c[i+];
}
int cnt=;
for(int i=; i<=k; i++)
{
for(int j=; j<i; j++)
{
LL m=sum[i]-sum[j];
g[m]++;
cnt++;
}
}
if(a==)
{
ans=*(cnt-g[])*g[]+g[]*g[];
}
else
{
ans=;
for(int i=; i<; i++)
{
if(a/i<&&a%i==)
{
ans+=g[i]*g[a/i];
}
}
}
printf("%I64d\n",ans);
}
return ;
}

cf C. Matrix的更多相关文章

  1. CF 1042 E. Vasya and Magic Matrix

    E. Vasya and Magic Matrix http://codeforces.com/contest/1042/problem/E 题意: 一个n*m的矩阵,每个位置有一个元素,给定一个起点 ...

  2. 【CF edu 30 C. Strange Game On Matrix】

    time limit per test 1 second memory limit per test  256 megabytes input standard input output standa ...

  3. [CF #236 (Div. 2) E] Strictly Positive Matrix(强联通分量)

    题目:http://codeforces.com/contest/402/problem/E 题意:给你一个矩阵a,判断是否存在k,使得a^k这个矩阵全部元素都大于0 分析:把矩阵当作01矩阵,超过1 ...

  4. CF 274D Lovely Matrix 拓扑排序,缩点 难度:2

    http://codeforces.com/problemset/problem/274/D 这道题解题思路: 对每一行统计,以小值列作为弧尾,大值列作为弧头,(-1除外,不连弧),对得到的图做拓扑排 ...

  5. [CF] 402 E. Strictly Positive Matrix

    一个矩阵,自乘无限次后能否全为正数? 如果n比较小,可以二分一下,但是这里n很大,乘一次都无法接受 可以考虑实际含义:矩阵看成邻接矩阵,那么0就是没有边,其余就是有边. 我们知道邻接矩阵自乘k次就相当 ...

  6. cf div2 234 D

    D. Dima and Bacteria time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  7. 【NOIP模拟】matrix(简化矩阵)

    题目背景 SOURCE:NOIP2016-RZZ-1 题目描述 给出两个 N×N 的矩阵 A.B,矩阵每行每列标号 0-N-1 .定义这两个矩阵的乘积 AB 为

  8. 推荐系统算法学习(一)——协同过滤(CF) MF FM FFM

    https://blog.csdn.net/qq_23269761/article/details/81355383 1.协同过滤(CF)[基于内存的协同过滤] 优点:简单,可解释 缺点:在稀疏情况下 ...

  9. [cf div 2 706E] Working routine

    [cf div 2 706E] Working routine Vasiliy finally got to work, where there is a huge amount of tasks w ...

随机推荐

  1. 利用ftrace跟踪内核static tracepoint——实例writeback event

    摘要:和很多linux内核子系统一样,static tracepoint有很多层次,其中某个层次都展示给不同层次的开发者来满足他们的不同需求.关于linux tracepoint的详细信息,我们可以在 ...

  2. Android视图框架

    Android视图框架 Android的UI系统是android应用系统框架最核心,最基础的内容! 1. Android视图系统.层次关系 Android应用设计和Web应用设计类似,也分前端和后端设 ...

  3. hdu 2583 permutation 动态规划

    Problem Description Permutation plays a very important role in Combinatorics. For example ,1 2 3 4  ...

  4. JAVA二维数组小记

    入手JAVA第二天 //二维数组 //数据类型 [][] 数组名 = new 数据类型[行的个数][列的个数];3 String [][] name = {{"admin",&qu ...

  5. Showing 2 changed files with 3 additions and 3 deletions.

    4  lib/matplotlib/__init__.py View   @@ -126,9 +126,9 @@ def compare_versions(a, b):     else: ...

  6. 一年后重翻javascript

      回想下自己的工作历程  一年多的ios开发眨眼间就过去了  不过这一切还没有结束,紧随其后的便是前段开发,虽然顶点基础都没有,但是还是通过我的不懈努力最终成功转型,虽然刚开始是通过jq直接入门的 ...

  7. auto and static key words

    ---恢复内容开始--- 对堆栈怎样实现函数调用的描述也同时解释了为什么不能从函数中返回一个指向该函数局部自动变量的指针,例如: 当进入该函数时,自动变量deciduous在堆栈中分配.但函数结束后, ...

  8. js获取每个按键的ASCII值

    通过js绑定键盘按下事件onkeydown获取每个按键的ascII值. js获取每个按键的ascii值 <script language="javascript"> / ...

  9. next数组

    首先看看next数组值的求解方法例如: 模式串 a b a a b c a c next值 0 1 1 2 2 3 1 2               next数组的求解方法是:第一位的next值为0 ...

  10. mvc自带的异步表单提交

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...