Броеви#

C++#

//v10
#include <iostream>
 
using namespace std;
 
int main()
{
    int z, r, x, y;
    
    cin >> z >> r;
    
    x=(z+r)/2;
    y=z-x;
    
    if(x>=0  &&  y>=0  &&  (z+r)%2==0)
        cout << x << " " << y << endl;
    else 
        cout << "NE MOZE" << endl;
        
    return 0;
}

Продавница#

C++#

//v10
#include <iostream>
 
using namespace std;
 
int main()
{
   int x,y,k,petka=0,dvojka=0,kec=0;
 
   cin>>x>>y;
        k=y-x;
   while(k>0){
   while(k>=5)
   {
       k=k-5;
       petka++;
   }
    while(k>=2)
    {
        k=k-2;
        dvojka++;
    }
    while(k>=1)
    {
        k=k-1;
        kec++;
    }
   }
  cout<<petka+dvojka+kec;
 
    return 0;
}

Бројот 9#

C++#

//v10
#include <iostream>
 
using namespace std;
 
int main()
{
    int n, m, a=0, b, c;
    long long sum=0;
    string broj;
    
    cin >> str;
    
    for(int i=0;i<broj.size();i++){
        suma+=broj[i]-48;              //-48 или -'0' за да се конвертира од ASCII во декаден
    }
    
    if(suma%9==0)
        cout << 0 << endl;
    else if(suma%3==0)
        cout << 2 << endl;          //Ако е делив со 3, а не со 9 треба да се додаде збирот уште 2 пати
    else 
        cout << 8 << endl;          //Ако не е делив со 3 и 9, тогаш бројот е заемно прост со 9,
                                    //треба да се собере уште 8 пати
                                    
    return 0;
}

Мечето ушко#

C++#

//Филип Бујаровски
#include <iostream>  
#include <cstring>  
#include <cmath>  
#include <math.h>  

using namespace std;  
      
    int main(){  

        int i, j, n, k, zbir=0;  
        cin>>n;
          
        int niza[n];  
        
        for(i=0;i<n;i++)  
        {  
              cin>>niza[i];  
              zbir+=niza[i];  
        }  
        
        int x;  
        bool c[(zbir)+1];  
        
        memset(c,false,sizeof(c));  
        c[0]=true;  
        
        for(i=0;i<n;i++)  
        {  
              k=niza[i];  
              for(j=zbir;j>=0;j--)  
              {  
                    x=j+k;  
                    if(c[j]==true)  
                    {  
                          if(j+k<zbir)  
                          c[j+k]=true;  
                    }  
              }  
        }  
      
        int p=0,q=0;  
          for(i=zbir/2;i>=0;i--)  
          {  
                if(c[i]==true)  
                {  
                      p=i;  
                      break;  
                }  
          }  
          q=zbir-p;  
          cout<<fabs(p-q)><<endl;  
      
      
        return 0;  
    }  

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
cpp
main.cpp 0.3 kB 4 20-Aug-2015 17:35 metotra Инженер, регионален 2013, напредна група
« This page (revision-6) was last changed on 08-Nov-2015 12:45 by Penkov