POJ 3112 Digital Biochemist Circuit
来源:互联网 发布:ubuntu怎么稳定翻墙 编辑:程序博客网 时间:2024/06/05 15:37
Description
A digital biochemist circuit (DBC) is a device composed of a set of processing nodes. Each processing node consists of a small receptacle for holding biochemist agents. The receptacle is made of a biological substance that works like a digital circuit. Depending on the states of reactions in the receptacle, the substance may generate two levels of voltage. A reader connected to a DBC is capable of reading all processing nodes of the DBC instantaneously, interpreting the two levels of voltage as 0 or 1.
An experiment with the DBC is carried out in the following way. The processing nodes are loaded with the substances of interest and appropriate reagents and, for every fixed time interval (typically several milliseconds), the voltage of processing nodes are read. Thus, the experiment results in a sequence of bit sets (vectors), each corresponding to a measurement of the DBC.
A sequence of 1-bits uninterrupted throughout the time of a processing node is called a run. The length of a run is the number of 1-bits in the sequence (note that the length of runs of an experiment can vary between one and the number of measurements made). One important characteristic of an experiment with the DBC is the number and length of the runs generated. The figure below shows the result of an experiment carried out with a DBC of six processing nodes, on which four measurements are made, containing three runs of length one, one run of length two and one run of length four.
0 1 0 1 1 00 0 0 1 0 00 1 0 1 0 10 1 0 1 0 0
You are contracted to write a program that determines, given the result of an experiment, how many runs of length that is equal to or greater than a certain value are generated.
Input
The input contains several test cases. The first line of test case contains three integers P, N and C which indicate the number of processing nodes (1 ≤ P ≤ 1000), the number of measurements made (1 ≤ N ≤ 1000) and the minimum length of runs of interest (1 ≤ C ≤ N), respectively. Each of the next N lines contains P digits {0, 1} separated by a whitespace. The end of the input is indicated by P = N = C = 0.
Output
For each test case in the input your program should produce a single line of output, containing the number of runs of length greater than or equal to C produced by the experiment.
Sample Input
2 2 21 11 14 5 30 1 0 11 1 1 11 0 0 11 0 1 11 1 0 00 0 0
Sample Output
22
题目的意思是,有p个 电子元件, 跑n次;
每行是每次各个电子元件状态.
所以竖着的连续的1,代表某电子元件的runs. 同一个电子元件可以有多个0间隔开的runs; 计算长度大于c 的runs个数
#include<stdio.h>int mp[2000][2000];int main(){int p,n,c,i,j,sum,ans; while(scanf("%d%d%d",&p,&n,&c),p||n||c) { for(i=1;i<=n;i++) { for(j=1;j<=p;j++) { scanf("%d",&mp[i][j]); } } ans=0; for(j=1;j<=p;j++)//每列 { sum=0; for(i=1;i<=n;i++) { if(mp[i][j]==1) sum++; else sum=0; if(sum==c) ans++; } } printf("%d\n",ans); } return 0;}
- POJ 3112 Digital Biochemist Circuit
- poj 3112 Digital Biochemist Circuit(简单题)
- APS Interview - Digital Circuit and Digital Logic I
- poj 1041 Eulerian Circuit
- POJ 1519 Digital Roots
- poj 1519 Digital Roots
- POJ 1519 Digital Roots
- POJ 1519 digital root
- poj 1519 Digital Roots
- POJ 1519 Digital Roots
- POJ 1519:Digital Roots
- POJ 1519 Digital Roots G++
- POJ 3055 Digital Friends 笔记
- Poj 2284 Hoj 1890 That Nice Euler Circuit
- poj 2284 That Nice Euler Circuit 计算几何
- POJ 2284 That Nice Euler Circuit (LA 3263 HDU 1665)
- POJ--2284--That Nice Euler Circuit【平面图欧拉公式】
- That Nice Euler Circuit - POJ 2284 欧拉公式
- TCP/IP协议族结构图
- ContentProvider何时创建?SQLiteDatabase方法何时执行?
- ACM 注意事项 (不定时更新)
- 64位系统由于找不到32位程序加载器而无法运行32位程序的分析过程
- Linux音频编程指南
- POJ 3112 Digital Biochemist Circuit
- Fiddler Web Debugger查看Http报文信息使用说明
- Java Runtime.exec 调用linux SCP 命令Copy 远程机器上的目录失败
- 通用线程:POSIX 线程详解,第 2部分
- 通用线程:POSIX 线程详解,第 3 部分
- [LeetCode] Divide Two Integers
- hdoj 2674 N!Again 【同余定理】+【找规律】
- C语言计算浮点数的小数位数,屏蔽掉了浮点运算的误差
- js数组的操作