Advertisement
Hezov

Subsets1 #4708

Oct 13th, 2024
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | Source Code | 0 0
  1. /// Pbinfo - #4708
  2. /// Formula : n * 2^(n-1)
  3. #include <fstream>
  4. using namespace std;
  5. ifstream cin("subsets.in");
  6. ofstream cout("subsets.out");
  7. struct nrMare{
  8.     int a[10000] = {0};
  9.     void operator  = (int n)
  10.     {
  11.         do {a[++a[0]] = n%10, n/=10;}  while(n);
  12.     }
  13.     void operator *= (int x)
  14.     {
  15.         int t = 0;
  16.         for(int i = 1;i<=a[0];i++,t/=10)
  17.             t+=a[i]*x, a[i] = t%10;
  18.         while(t>0) a[++a[0]] = t%10, t/=10;
  19.     }
  20.     void afisare()
  21.     {
  22.         for(int i = a[0];i>0;i--)
  23.             cout<<a[i];
  24.     }
  25. };
  26. int main()
  27. {
  28.     int n, p = 0; cin>>n;
  29.     nrMare sol;
  30.     sol = n;
  31.     while(p+10<=n-1)
  32.         sol*=(1<<10),p+=10;
  33.     while(p+1<=n-1)
  34.         sol*=2,p++;
  35.     sol.afisare();
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement