Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <string.h>
- #include <vector>
- #include <sstream>
- #include <time.h>
- #include <stdio.h>
- #include <math.h> /* sqrt */
- using namespace std;
- stringstream stream;
- //vector <int> niz(0);
- //int numbers[] = {};
- vector <int> cordinateX(0);
- vector <int> cordinateY(0);
- string input;
- int nBroiTochki = 0;
- int D_razstoqnie = 0;
- void solve()
- {
- // D_razstoqnieMin = 1;
- // cout << "vliza v solve" << endl;
- for(int j =1; j<=D_razstoqnie; j++)
- {
- // cout << "vliza vuv 1 for" << endl;
- int groupsCounter = 0;
- for(int i =0; i<=nBroiTochki; i+=2)
- {
- //cout << "vtori for" << endl;
- double tempX1 = cordinateX[i];
- double tempY1 = cordinateY[i];
- double tempX2 = cordinateX[i+1];
- double tempY2 = cordinateY[i+1];
- double distanceBetweenTwoPoints = sqrt(pow((tempX2-tempX1),2) +pow((tempY2-tempY1),2));
- if(distanceBetweenTwoPoints>j)
- {
- groupsCounter++;
- }
- }
- int temp = groupsCounter+1;
- if((temp== nBroiTochki)&& (nBroiTochki>2))
- {
- groupsCounter++;
- // cout << "vliza tuk" << endl;
- }
- // cout << "Groups counter: " << groupsCounter << endl;
- //
- cout << groupsCounter << " ";
- // cout << groupsCounter << " ";
- // cout << "j kolko e " << j<< endl;
- }
- }
- long sstoi(const char *s) // custom stoi function
- {
- long i;
- i = 0;
- while(*s >= '0' && *s <= '9')
- {
- i = i * 10 + (*s - '0');
- s++;
- }
- return i;
- }
- int main()
- {
- clock_t tStart = clock();
- /* Do your stuff here */
- int tempNumber = 0;
- while(cin >>nBroiTochki)
- {
- cin.ignore();
- cin >> D_razstoqnie;
- cin.ignore();
- getline(cin,input);
- stream.str(input);
- // cout << "NbroiTochki " << nBroiTochki << endl;
- int n = nBroiTochki;
- while(n--)
- {
- stream >> tempNumber;
- cordinateX.push_back(tempNumber);
- stream >> tempNumber;
- cordinateY.push_back(tempNumber);
- }
- stream.clear();
- //cout << "NbroiTochki " << nBroiTochki << endl;
- // cout << "D razstoqnie"<< D_razstoqnie << endl;
- /* for(int i =0; i<nBroiTochki; i++)
- {
- cout << "cordinate X val: " << cordinateX[i] << "cordinate Y val: " << cordinateY[i] << endl;
- }
- */
- solve();
- cordinateX.clear();
- cordinateY.clear();
- }
- //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
- }
- // Работи с много output
Add Comment
Please, Sign In to add comment