Advertisement
Guest User

Untitled

a guest
Apr 10th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <sstream>
  7. using namespace std;
  8.  
  9.  
  10. vector<unsigned long long> removeDupWord(string str) {
  11.     stringstream stream(str);
  12.     vector<unsigned long long> theIntegers;
  13.     vector<int> sequence;
  14.     while(1) {
  15.         unsigned long long n;
  16.         stream >> n;
  17.         if(!stream) {
  18.             break;
  19.         }
  20.         theIntegers.push_back(n);
  21.     }
  22.  
  23.     int twoThirtyOne = (int)pow(2,31);
  24.     int valueOne = ((int)(theIntegers.at(1) % (twoThirtyOne)));
  25.     sequence.push_back(valueOne);
  26.     for(int j = 1; j < (theIntegers.size()-1); j++){
  27.         unsigned long long firstPart = ((theIntegers.at(j-1)*theIntegers.at(2))+theIntegers.at(3));
  28.         int valueTwo = ((int)(firstPart % twoThirtyOne));
  29.         sequence.push_back(valueTwo);
  30.     }
  31.  
  32.     for(int i = 0; i < sequence.size(); i++){
  33.         cout << sequence.at(i) << " ";
  34.     }
  35.     cout << "\n";
  36.     return theIntegers;
  37. }
  38.  
  39.  
  40. int main() {
  41.     string integers;
  42.     getline(cin,integers);
  43.     vector<unsigned long long> leftOvers = removeDupWord(integers);
  44.     for(int i = 0; i < leftOvers.size(); i++) {
  45.         cout << leftOvers.at(i) << " ";
  46.     }
  47.     cout << "\n";
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement