wiktortokumpel

spoj

Nov 15th, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. using namespace std;
  5. void segmentowiec()
  6. {
  7.     int t; //liczba segmentów
  8.     cin>>t;
  9.     for(int i=0;i<t;i++)
  10.     {
  11.         int n;
  12.         cin>>n;
  13.         int tab[n];
  14.         for(int j=0;j<n;j++)
  15.         {
  16.             int x;
  17.             cin>>x;
  18.             tab[j]=x;
  19.         }
  20.         int dni=-1;
  21.         dni+=n;
  22.         for(int j=0;j<n;j++)
  23.             dni+=tab[j];
  24.         cout<<dni<<endl;
  25.     }
  26. }
  27.  
  28.  
  29.  
  30. void przedszkolanka()
  31. {
  32.     int N,a,b,c;
  33.  
  34.     cin>>N>>a>>b;
  35.         for(int i=0;i<N;i++)
  36.         {
  37.          if(a<b)
  38.          {
  39.              while(c%a!=0 or c%b!=0)
  40.              {
  41.                  c+=b;
  42.              }
  43.          }
  44.          else
  45.          {
  46.              while(c%a!=0 or c%b!=0)
  47.              {
  48.                  c+=a;
  49.              }
  50.          }
  51.  
  52.         }
  53.         cout<<c;
  54. }
  55. int main()
  56. {
  57. //    segmentowiec();
  58.     przedszkolanka();
  59.     /*ios_base::sync_with_stdio(0);
  60. const int SIZE = 1000000010;
  61. vector <int> liczbyPierwsze;
  62.  
  63. for(int i = 2; i <= sqrt(SIZE); i++) {
  64. if(tab[i]) continue;
  65. liczbyPierwsze.push_back(i*i);
  66. for(int j = 2*i; j <= sqrt(SIZE); j += i)
  67. tab[j] = true;
  68. }
  69.  
  70. int a, b, t;
  71.  
  72. cin >> t;
  73.  
  74. while(t--) {
  75. cin >> a >> b;
  76. int zlicz = 0;
  77. for(int i = 0; i < liczbyPierwsze.size(); i++) {
  78. if(liczbyPierwsze[i] >= a && liczbyPierwsze[i] <= b)
  79. zlicz++;
  80. if(liczbyPierwsze[i] > b)
  81. break;
  82. }
  83. cout << zlicz << endl;*/
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment