fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define YES cout << "YES\n";
  4. #define NO cout << "NO\n";
  5. #define opps cout<<-1<<endl;
  6. const ll con = 1e10 + 5;
  7. using namespace std;
  8. int getex(int x) {
  9. return (x % 4);
  10. }
  11. ll powx(int base, int x) {
  12. return pow(base, x);
  13. }
  14. void solve() {
  15. string s;
  16. cin >> s;
  17. int x = (s[s.length() - 1] - '0') ;
  18. (s.length() > 1 ) ? x += 10 * (s[s.length() - 2] - '0') : x += 0;
  19. int ex = getex(x);
  20. ll sumx = powx(1 , ex) + powx(2 , ex)+powx(3 , ex) + powx(4 , ex);
  21. cout<<sumx % 5 ;
  22. }
  23. int main() {
  24. ios::sync_with_stdio(0);
  25. cin.tie(0);
  26. int t = 1;
  27. //cin>>t;
  28. while(t--)
  29. solve();
  30. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
4