Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize("Ofast")
- #pragma GCC optimize("fast-math")
- #pragma GCC optimize("unroll-loops")
- #include <iostream>
- #include <vector>
- #include <sstream>
- #include <cmath>
- #include <algorithm>
- #include <string>
- #include <cstdio>
- #include <fstream>
- #include <climits>
- #include <map>
- #include <set>
- #include <deque>
- #include <tuple>
- using namespace std;
- #define sz(x) int(x.size())
- #define beg(x) x.begin(), x.end()
- #define pow2(x) ((x)*(x))
- #define get_auto(x) for (auto& var : x) {cout<<var<<' ';}
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- typedef vector < ll > vll;
- typedef vector < int > vi;
- typedef vector < pair<int, int> > vii;
- int x,y,c;
- vector<int> slozhen;
- vector<int> umnozh;
- set<int> sod;
- map<int,int> un_sod;
- int main() {
- string s1,s2,s3,s4;
- //Input
- cout<<"Vvedite ishodnoe chislo: ";
- cin>>x;
- cout<<"Vvedite neobhodimoe chislo: ";
- cin>>y;
- getline(cin,s3);
- cout<<"Vvedite operacii slozhenia v 1 stroku:\n";
- getline(cin,s1);
- cout<<"Vvedite operacii umnozhenia v 1 stroku:\n";
- getline(cin,s2);
- cout<<"Vvedite soderzhah cifri v 1 stroku:\n";
- getline(cin,s3);
- cout<<"Vvedite ne_soderzhah cifri v 1 stroku:\n";
- getline(cin,s4);
- //Initialization
- vector<int> v(y+1);
- int predel = x;
- //String processing
- stringstream str1(s1);
- stringstream str2(s2);
- stringstream str3(s3);
- stringstream str4(s4);
- while(str1>>c)
- slozhen.push_back(c);
- while(str2>>c)
- umnozh.push_back(c);
- while(str3>>c)
- sod.insert(c);
- while(str4>>c)
- un_sod[c]=1;
- v[x]=1;
- for (int i = x; i <=y ; ++i) {
- if (un_sod[i]==1) {
- v[i] = 0;
- continue;
- }
- for (auto &var: sod) {
- if(i>var){
- predel=var;
- }else
- break;
- }
- for(auto &var: slozhen){
- if(i-var>=predel){
- v[i]+=v[i-var];
- }
- }
- for(auto &var: umnozh){
- if((i%var)==0 && (i/var)>=predel){
- v[i]+=v[i/var];
- }
- }
- }
- for (int i = x; i < sz(v); ++i) {
- cout<<i<<": "<<v[i]<<endl;
- }
- cout<<endl<<"ANSWER:"<<v[sz(v)-1];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement