首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

codeforces 进制01有关问题

2012-11-07 
codeforces 进制01问题题目连接:http://codeforces.com/problemset/problem/165/C题目看起来很难,反正我是

codeforces 进制01问题

题目连接:http://codeforces.com/problemset/problem/165/C

题目看起来很难,反正我是被吓坏了

题目代码:

#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>#include<cmath>using namespace std;char s[1000005];long long dp[1000005];int main(){dp[0]=1;int i,d=0,k;long long ans=0;scanf("%d%s",&k,s);int l=strlen(s);for(i=0;i<l;++i){if(s[i]=='1') ++d;if(d>=k) ans+=dp[d-k];++dp[d];}cout<<ans<<endl;return 0;}

热点排行