fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int TEN = 10;
  5. const int HUNDRED = 100;
  6. const int THOUSAND = 1000;
  7.  
  8. int main() {
  9. int n;
  10. cin >> n;
  11. int units = 0, tens = 0, hundreds = 0, thousands = 0;
  12. if (n >= HUNDRED && n < THOUSAND) {
  13. units = n % TEN;
  14. tens = n / TEN % TEN;
  15. hundreds = n / HUNDRED % TEN;
  16. //cout << units << " " << tens << " " << hundreds;
  17. if ((n % TEN == n / HUNDRED) && (n / HUNDRED == n / TEN % TEN)) {
  18. cout << "DA";
  19. } else {
  20. if (units == hundreds && hundreds != tens) {
  21. cout << "APROAPE ";
  22. } else if (units == tens && tens != hundreds) {
  23. cout << "APROAPE ";
  24. } else if (tens == hundreds && tens != units) {
  25. cout << "APROAPE ";
  26. }
  27. }
  28. if ((units != tens) && (tens != hundreds)) {
  29. cout << "NU";
  30. }
  31. }
  32.  
  33. if (n >= THOUSAND ) {
  34. units = n % TEN;
  35. tens = n / TEN % TEN;
  36. hundreds = n / HUNDRED % TEN;
  37. thousands = n / THOUSAND;
  38. //cout << units << " " << tens << " " << hundreds << " " << thousands;
  39. if ((thousands == hundreds) && (thousands == tens) && (thousands == units)) {
  40. cout << "DA1";
  41. } else {
  42. if ((thousands == hundreds) && (thousands == tens) && (thousands != units)) {
  43. cout << "APROAPE1";
  44. } else if ((thousands == hundreds) && (thousands != tens) && (thousands == units)) {
  45. cout << "APROAPE2";
  46. } else if ((thousands != hundreds) && (thousands == tens) && (thousands == units)) {
  47. cout << "APROAPE3";
  48. } else if ((thousands != hundreds) && (hundreds == tens) && (tens == units)) {
  49. cout << "APROAPE4";
  50. }
  51. }
  52. if ((thousands != hundreds) && (thousands != tens) || (hundreds != tens) && (thousands != units)) {
  53. cout << "NU";
  54. }
  55. }
  56. return 0;
  57. }
Success #stdin #stdout 0s 5324KB
stdin
1221
stdout
NU