Advertisement
erfanul007

UVa 10948

Jan 19th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int > pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define sc scanf
  14. #define pf printf
  15. #define sci(n) scanf("%d",&n)
  16. #define scl(n) scanf("%lld",&n)
  17. #define scf(n) scanf("%lf",&n)
  18. #define pfi(n) printf("%d",n)
  19. #define pfl(n) printf("%lld",n)
  20. #define pff(n) cout<<n
  21. #define line printf("\n")
  22. #define spc printf(" ")
  23. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  24. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  25. #define cspf(i) printf("Case %d: ", i)
  26. #define pb push_back
  27. #define mp make_pair
  28. #define ff first
  29. #define ss second
  30. #define all(v) v.begin(),v.end()
  31. #define rall(v) v.rbegin(),v.rend()
  32. #define read() freopen("input.txt", "r", stdin)
  33. #define write() freopen("output.txt", "w", stdout)
  34. /// Constants
  35. #define eps 1e-9
  36. #define PI acos(-1.0) // 3.1415926535897932
  37.  
  38. vi prime,chk(1000009);
  39.  
  40. void seive(){
  41. chk[0]=1;
  42. chk[1]=1;
  43. prime.pb(0);
  44. for(int i=2;i<=1000000;i++){
  45. if(chk[i]==1)
  46. continue;
  47. prime.pb(i);
  48. for(int j=2;i*j<=1000000;j++){
  49. chk[i*j]=1;
  50. }
  51. }
  52. /*int sz=prime.size();
  53. loop(i,1,100){
  54. cspf(i);
  55. pfi(prime[i]);
  56. line;
  57. }*/
  58. }
  59.  
  60.  
  61. int main()
  62. {
  63. seive();
  64. read();
  65. write();
  66. int n;
  67. while(1){
  68. int x,y,flg=0;
  69. sci(n);
  70. if(n==0)
  71. break;
  72. for(int i=1;prime[i]<=n/2;i++){
  73. int dff=n-prime[i];
  74. if(chk[dff]==1)
  75. continue;
  76. x=prime[i];
  77. y=dff;
  78. flg=1;
  79. break;
  80. }
  81. if(flg)
  82. pf("%d:\n%d+%d\n",n,x,y);
  83. else
  84. pf("%d:\nNO WAY!\n",n);
  85. }
  86. return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement