Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- #include <sstream>
- using namespace std;
- vector<unsigned long long> removeDupWord(string str) {
- stringstream stream(str);
- vector<unsigned long long> theIntegers;
- vector<int> sequence;
- while(1) {
- unsigned long long n;
- stream >> n;
- if(!stream) {
- break;
- }
- theIntegers.push_back(n);
- }
- int twoThirtyOne = (int)pow(2,31);
- int valueOne = ((int)(theIntegers.at(1) % (twoThirtyOne)));
- sequence.push_back(valueOne);
- for(int j = 1; j < (theIntegers.size()-1); j++){
- unsigned long long firstPart = ((theIntegers.at(j-1)*theIntegers.at(2))+theIntegers.at(3));
- int valueTwo = ((int)(firstPart % twoThirtyOne));
- sequence.push_back(valueTwo);
- }
- for(int i = 0; i < sequence.size(); i++){
- cout << sequence.at(i) << " ";
- }
- cout << "\n";
- return theIntegers;
- }
- int main() {
- string integers;
- getline(cin,integers);
- vector<unsigned long long> leftOvers = removeDupWord(integers);
- for(int i = 0; i < leftOvers.size(); i++) {
- cout << leftOvers.at(i) << " ";
- }
- cout << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement