fork download
  1. // author : anphung
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define file "SOCHAN"
  5. #define int64 long long
  6. #define f0(i,a,b) for(int (i) = (a); (i) <= (b); ++i)
  7. #define TIME (1.0*clock()/CLOCKS_PER_SEC)
  8.  
  9. int64 n;
  10.  
  11. int64 s(int64 n){
  12. int64 sum = 0;
  13. while(n){
  14. sum += n%10;
  15. n/=10;
  16. }
  17. return sum;
  18. }
  19.  
  20. void trau(){
  21. int64 cnt = 0;
  22. f0(i,1,n){
  23. if(s(i)%2==0){
  24. cnt++;
  25. }
  26. cout<<i<<" "<<cnt<<'\n';
  27. }
  28. cout<<cnt;
  29. }
  30.  
  31. void sub(){
  32. if(s(n)%2==0){
  33. if(n%2==0){
  34. cout<<n/2;
  35. }else if(n%2!=0){
  36. cout<<n/2;
  37. }
  38. }else if(s(n)%2!=0){
  39. if(n%2==0){
  40. cout<<n/2-1;
  41. }else if(n%2!=0){
  42. cout<<n/2;
  43. }
  44. }
  45. }
  46.  
  47. int32_t main(){
  48. ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  49. freopen(file".inp","r",stdin);
  50. freopen(file".out","w",stdout);
  51.  
  52. cin>>n;
  53. sub();
  54.  
  55. //cerr<<"\ntime elapsed: "<<TIME <<"s.\n";
  56. }
  57.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty