解说Codeforces Round #213 (diy.2) C.Matrix
来源:互联网 发布:淘宝buy功能哪里打开 编辑:程序博客网 时间:2024/05/22 13:08
题目大意:
用题目中的方法构造一个矩阵。
然后求出矩阵中长方形的和等于a的长方形的数量
思路:
长方形的和 等于构成它的长的那些数字的和 加上构成它的宽的那些数字的和
两个和的积
比如第一个样例
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
自己去体会吧~~~哈哈
那么我们枚举出来S可以凑出的数字
然后行和列能凑出来的东西是一样的
那么枚举出现过的东西 然后去凑出a
当a==0的时候特判一下就Ok啦
记得longlong
[cpp] view plaincopy
#include
#include
#include
#include
#include
#include
typedef long long LL;
using namespace std;
LL cnt[40005];
int main()
{
int m;
char str[40005];
LL t[40005];
memset(cnt,0,sizeof(cnt));
scanf("%d",&m);
scanf("%s",str);
for(int i=0;i<strlen(str);i++)< p="">
t[i]=str[i]-'0';
int len=strlen(str);
for(int i=0;i<len;i++)< p="">
{
LL tot=0;
for(int j=i;j<len;j++)< p="">
{
tot+=t[j];
cnt[tot]++;
}
}
LL ans=0;
if(m==0)
for(int i=0;i<40000;i++)
ans+=cnt[0]*cnt[i];
for(int i=1;i<=40000;i++)
{
if(m%i==0)
{
if(m/i<=40000 && m/i>=0)ans+=cnt[i]*cnt[m/i];
}
}
//if(m==0)ans=len*cnt[0];
printf("%I64d\n",ans);
return 0;
}
- 解说Codeforces Round #213 (diy.2) C.Matrix
- Codeforces Round #213 (diy.2) C.Matrix
- Codeforces Round #213 (diy.2) C. Matrix
- Codeforces Round #213 (Div. 2) C Matrix
- Codeforces Round #217 (diy.2) C. Mittens
- Codeforces Round #215 (diy.2) C. Sereja and Algorithm
- Codeforces Round #216 (diy.2) C. Valera and Elections
- Codeforces Round #348 (div 2) C. Little Artem and Matrix
- Codeforces 400 C. Inna and Huge Candy Matrix【 Codeforces Round #234 (Div. 2)】
- Codeforces Round #213C
- Codeforces Round #215 (diy.2) B.Sereja and Suffixes
- Codeforces Round #217 (diy.2) A. Rook, Bishop and King
- Codeforces Round #217 (diy.2) B. Berland Bingo
- Educational Codeforces Round 30 C. Strange Game On Matrix
- Codeforces Div.2 213 C Matrix (预处理+哈希)
- 【codeforces】Codeforces Round #370 (Div. 2) C
- Codeforces Round #236 (Div. 2) E. Strictly Positive Matrix
- Codeforces Round #214 (diy.2) B. Dima and To-do List
- Hibernate 的 session 管理
- nginx+lua实现视频的过期防盗链
- primary key与unique的区别
- 怎样取消linux挂载磁盘不在桌面上显示
- linux下利用内核的random产生不重复的id
- 解说Codeforces Round #213 (diy.2) C.Matrix
- 种子搜索: PileFile Downloader
- Socks代理上网工具 tsocks
- radioGroup执行clearCheck会出现StackOverflowError错误
- linux5.5下安装mysql5.5.25注意问题和过程
- Linux中常用命令学习总结
- 好好利用Oracle存储过程返回结果集开发报表
- 一个多维数组所有元素输出问题
- QT 显示图像