#include <iostream> #include <sstream> #include <string> #include <deque> using namespace std; main (int arc, char ** argv) { deque<int> result; int n = 0; cin >> n; //cout << n << '\n'; int an = 0; int prev_an = 0; double prev_factor = 10000000; double factor = 0; //cout << "result:" << result <<'\n'; //set<string> zadania; for (int i = 1; i < n; i++) { cin >> an; //cout << str << '\n'; result.push_back(an - prev_an); //cout << "result:" << result <<'\n'; factor = an / i; if (factor < prev_factor) { prev_factor = factor; prev_an = an; } else { cout << "TAK" << '\n'; } } cout << "TAK" << '\n'; cout << result.size() <<'\n'; deque <int> :: iterator itr; for (itr = result.begin(); itr != result.end(); ++itr) { cout << *itr << " "; } cout << '\n'; //cout << "zadania.size()" << zadania.size() <<'\n'; return 0; }
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #include <iostream> #include <sstream> #include <string> #include <deque> using namespace std; main (int arc, char ** argv) { deque<int> result; int n = 0; cin >> n; //cout << n << '\n'; int an = 0; int prev_an = 0; double prev_factor = 10000000; double factor = 0; //cout << "result:" << result <<'\n'; //set<string> zadania; for (int i = 1; i < n; i++) { cin >> an; //cout << str << '\n'; result.push_back(an - prev_an); //cout << "result:" << result <<'\n'; factor = an / i; if (factor < prev_factor) { prev_factor = factor; prev_an = an; } else { cout << "TAK" << '\n'; } } cout << "TAK" << '\n'; cout << result.size() <<'\n'; deque <int> :: iterator itr; for (itr = result.begin(); itr != result.end(); ++itr) { cout << *itr << " "; } cout << '\n'; //cout << "zadania.size()" << zadania.size() <<'\n'; return 0; } |