Codeaforces 1335 A. Candies and Two Sisters Solution

  1. Solution in C++:
  2. ///**********ALLAH IS ALMIGHTY************///
  3. ///AH Tonmoy
  4. ///Department of CSE,23rd batch
  5. ///Islamic University,Bangladesh
  6. #include<bits/stdc++.h>
  7. using namespace std;
  8. int main()
  9. {
  10. int t,n,i,j;
  11. while(cin>>t)
  12. {
  13. while(t--)
  14. {
  15. cin>>n;
  16. if(n>2)
  17. {
  18. if(n%2==1)
  19. {
  20. cout<<n/2<<endl;
  21. }
  22. else
  23. cout<<(n/2)-1<<endl;
  24. }
  25. else
  26. cout<<"0"<<endl;
  27. }
  28. }
  29. }

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.