1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<iostream>
#include "poszukiwania.h"
#include "message.h"
using namespace std;
int main()
{
	long long x,y,z,p=0,q,a;
	x=SignalLength();
	y=SeqLength();
	for(z=MyNodeId()+1;z<=(y-x+1);z+=NumberOfNodes()){
		if(SignalAt(1)==SeqAt(z)){
			q=1;
			for(a=1;a<x;a++){
				if(SeqAt(z+a)==SignalAt(a+1))q++;	
				else break;
				}
			if(q==x)p++;
			}
	}
	if(MyNodeId()>0){
		PutLL(0,p);
		Send(0);
	}
	else {
		for(z=1;z<NumberOfNodes();z++){
			Receive(z);
			p+=GetLL(z);
		}
		cout<<p;
	}
	return 0;
}