A. Design Tutorial: Learn from Math(472A -A. Design Tutorial: Learn from Math)




  1. A. Design Tutorial: Learn from Math
  2. Examples
    input
    Copy
    12
    output
    Copy
    4 8
    input
    Copy
    15
    output
    Copy
    6 9
    input
    Copy
    23
    output
    Copy
    8 15
    input
    Copy
    1000000
    output
    Copy
    500000 500000
    Note
    In the first example, 12 = 4 + 8 and both 4, 8 are composite numbers. You can output "6 6" or "8 4" as well.
    In the second example, 15 = 6 + 9. Note that you can't output "1 14" because 1 is not a composite number.



  3. #include<iostream>
  4. using namespace std;
  5. int prime(int a)
  6. {int ok=0;
  7. int i;
  8. for(i=2;i<a;i++)
  9. {
  10. if(a%i==0)
  11. {
  12. ok=1;
  13.  
  14. }
  15. }
  16. if(ok==1)return 1;
  17. else return 0;
  18. }
  19. int main()
  20. {
  21. long int n;
  22. long int a,b;
  23. int i;
  24. cin>>n;
  25. a=4;
  26. b=n-4;
  27. for(i=1;i<=n;i++)
  28. {
  29.  
  30. int m=prime(a);
  31. int m2=prime(b);
  32. if(m==1 & m2==1)
  33. {cout<<a<<" "<<b<<endl;
  34. return 0;}
  35.  
  36. a++;b--;
  37. }
  38.  
  39. }

Comments

Popular posts from this blog

Codeforce Problem 1703A. YES or YES?

Aptitude test assistant programmer 2018

1041A. Heist solution