T3000

Lab1ProbA1

Feb 27th, 2026
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. bool prim(long long &a,long long &b){
  6.     if(a<=1 || b<=1){
  7.         return false;
  8.     }
  9.     if(a!=0){
  10.     for(int i=2;i<a;i++){
  11.         if(a%i==0){
  12.             return false;
  13.         }
  14.     }}
  15.     if(b!=2){
  16.     for(int i=2;i<b;i++){
  17.         if(b%i==0){
  18.             return false;
  19.         }
  20.     }
  21.     }
  22.     return true;
  23. }
  24. int main()
  25. {
  26.     long long n;
  27.     cin>>n;
  28.     for(long long i=1;i<n;i++){
  29.         for(long long j=1;j<n;j++){
  30.             if(prim(i,j) && i+j==n){
  31.                 cout<<i<<"+"<<j<<"="<<n<<endl;
  32.                 return 0;
  33.             }
  34.         }
  35.     }
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment