HUST - 1599 Multiple
input
长度不大于3*10e5的数字串
output
不含前导0的能整除64的字串的个数(0算一个,064不算)
一般数组中找能整除一个数的字串都是用取余来做的
用一个a[64]来存下从1-i位累加到第i位的余数为0-63的个数,每次都加上余数为0的个数,第一位为0的只统计一次,不加入a数组中
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; char s[];
int a[][],b[],sum,d; int main()
{
while(scanf("%s",s)==)
{
memset(a,,sizeof(a));
sum=;
d=;
for(int i=;s[i];i++)
{
memset(a[d^],,sizeof(a[]));
if(s[i]!='') a[d][]++;
else sum++;
for(int j=;j<;j++)
{
int t=j*+s[i]-'';
a[d^][t%]+=a[d][j];
}
sum+=a[d^][];
d^=;
}
printf("%d\n",sum);
}
return ;
}
HUST - 1599 Multiple的更多相关文章
- HUST 1599 - Multiple(动态规划)
1599 - Multiple 时间限制:2秒 内存限制:64兆 461 次提交 111 次通过 题目描述 Rocket323 loves math very much. One day, Rocke ...
- POJ 1426 Find The Multiple --- BFS || DFS
POJ 1426 Find The Multiple 题意:给定一个整数n,求n的一个倍数,要求这个倍数只含0和1 参考博客:点我 解法一:普通的BFS(用G++能过但C++会超时) 从小到大搜索直至 ...
- hust 1385 islands 并查集+搜索
islands Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/problem/show/1385 Descri ...
- Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define ...
Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define ... 这个错误是因为有两个相 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- [LeetCode] Read N Characters Given Read4 II - Call multiple times 用Read4来读取N个字符之二 - 多次调用
The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actu ...
- SharePoint "System.Data.SqlClient.SqlException (0x80131904): Parameter '@someColumn' was supplied multiple times.“
最近在处理SharePoint Office365的相关开发的时候发现了这样一个奇怪的现象: 无法通过API更新Editor field,只要已更新就会throw Exception,由于是Offic ...
- 2012Chhengdu K - Yet Another Multiple Problem
K - Yet Another Multiple Problem Time Limit:20000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- JAVA实现AES 解密报错Input length must be multiple of 16 when decrypting with padded cipher
加密代码 /**解密 * @param content 待解密内容 * @param password 解密密钥 * @return */ public static byte[] decrypt(b ...
随机推荐
- POJ 2599 A funny game#树形SG(DFS实现)
http://poj.org/problem?id=2599 #include<iostream> #include<cstdio> #include<cstring&g ...
- hdu_5858_Hard problem(数学题)
题目链接:hdu_5858_Hard problem 题意: 让你求阴影部分面积 题解: 推推公式就行 #include<stdio.h> #include<math.h> # ...
- hive UDF添加方式
hive UDF添加的方式 1.添加临时函数,只能在此会话中生效,退出hive自动失效 hive> add jar /home/jtdata/hiveUDF/out0.jar; Added [/ ...
- JS 之完美运动框架 如何同时改变元素多个属性?
正如改变一个属性的方法,可以使用已经写好的运动函数如move(obj,attr,target,fn);我们可能会想这样做, 调用两次运动函数,如同时改变宽和高,move(obj,'width',tar ...
- Excel教程(2) - 函数的参数
函数右边括号中的部分称为参数,假如一个函数可以使用 多个参数,那么参数与参数之间使用半角逗号进行分隔.参数 可以是常量(数字和文本).逻辑值(例如 TRUE 或 FALSE).数 组.错误值(例如#N ...
- Myeclipse 激活代码 8.6以前的版本
public class Akey { private static final String LL = "Decompiling this copyrighted software is ...
- 2015 ACM/ICPC Asia Regional Changchun Online
1001 Alisha’s Party 比赛的时候学长stl吃T.手写堆过. 赛后我贴了那两份代码都过.相差.2s. 于是用stl写水果. # include <iostream> # i ...
- 第19讲 不带参数功能FC的编程与应用
- json 与entity/list/map的转换
一 json -> entity User.java package com.xxx.hotel.train.json.json2entity; import java.io.Serializ ...
- 计算机网络分层(OSI七层、 TCP/IP四层)