fork(6) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void poprawny(string pesel)
  6. {
  7. int suma=0;
  8. suma+=((pesel[0] - '0') * 1);
  9. suma+=((pesel[1] - '0') * 3);
  10. suma+=((pesel[2] - '0') * 7);
  11. suma+=((pesel[3] - '0') * 9);
  12. suma+=((pesel[4] - '0') * 1);
  13. suma+=((pesel[5] - '0') * 3);
  14. suma+=((pesel[6] - '0') * 8);
  15. suma+=((pesel[7] - '0') * 9);
  16. suma+=((pesel[8] - '0') * 1);
  17. suma+=((pesel[9] - '0') * 3);
  18. suma+=((pesel[10] - '0') * 1);
  19. if (suma>0)
  20. {
  21. if (suma%10==0)
  22. {
  23. cout<<"D"<<endl;
  24. }
  25. else
  26. {
  27. cout<<"N"<<endl;
  28. }
  29. }
  30. else cout<<"N"<<endl;
  31. }
  32. int main()
  33. {
  34. int testy;
  35. string pesel;
  36. cin>>testy;
  37. for (int i=0; i<testy; i++)
  38. {
  39. cin>>pesel;
  40. poprawny(pesel);
  41. }
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0s 15240KB
stdin
2
00000000000
91111111118
stdout
N
N