Advertisement
raju02

UVA the hug one 13444

Nov 27th, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. int num (string s , int p)
  5. {
  6. int n = 0;
  7.  
  8. for(int i = 0; i < s.length(); i++)
  9. {
  10. n = n * 10 + s[i] - '0';
  11.  
  12. n = n % p;
  13. }
  14.  
  15. return n;
  16. }
  17. int main()
  18. {
  19. int tes, x , a;
  20.  
  21. string s1;
  22. bool k = false;
  23.  
  24. cin >> tes;
  25. while(tes--)
  26. {
  27. cin >> s1;
  28. cin >> x;
  29. int c = 0;
  30. for(int i = 0; i < x; i++)
  31. {
  32. cin >> a;
  33. if(num(s1 , a) == 0)
  34. {
  35. c++;
  36. }
  37. }
  38.  
  39. if(c == x)
  40. cout<<s1<<" - Wonderful."<<endl;
  41. else
  42. cout<<s1<<" - Simple."<<endl;
  43.  
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement