Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n, x, r, a, b, rez=1;
  8.     cin >> n;
  9.     for (int i = 1; i <= n; i++)
  10.     {
  11.         cin >> x;
  12.         a = n;
  13.         b = x;
  14.         r = a%b;
  15.             while (r!=0)
  16.             {
  17.                 a = b;
  18.                 b = r;
  19.                 r = a%b;
  20.             }
  21.         if (b==1)
  22.             rez = rez*x;
  23.     }
  24.     cout << rez;
  25.     return 0;
  26. }
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. #include "stdafx.h"
  38. #include <iostream>
  39. using namespace std;
  40.  
  41. int main()
  42. {
  43.     int n, p=2, x, y, c=1;
  44.     cin >> n; //1
  45.     cin >> x; //5
  46.     cin >> y; //10
  47.     while(c <= n)
  48.     {
  49.         p = p * 2; //4
  50.         if(p>=x)
  51.         {
  52.             if (p <= y)
  53.             {
  54.                 cout << p << endl;
  55.                 c++;
  56.             }
  57.         }
  58.     }
  59.     return 0;
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76. #include "stdafx.h"
  77. #include <iostream>
  78. using namespace std;
  79.  
  80. int main()
  81. {
  82.     int n, x, y,p=0,ctr=0
  83.     cin >> n
  84.     for(int i=1; i<=n; i++)
  85.     {
  86.         cin>>x;
  87.         y=x%10;
  88.         p=p*10+y;
  89.     }
  90. for(int k=2; k<=p/2; k++)
  91. {
  92. if(p%k==0)
  93. ctr++;
  94. }
  95. if(ctr)
  96. cout<<"Numarul "<<p<<" Nu este prim"<<endl;
  97. else
  98. cout<<"Numarul "<<p<<" Este prim"<<endl;
  99.     return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement