Submission #383622

#TimeUsernameProblemLanguageResultExecution timeMemory
383622nguyen31hoang08minh2003Sifra (COCI21_sifra)C++14
50 / 50
1 ms364 KiB
#include <bits/stdc++.h> #define fore(i, a, b) for (int i = (a), _b = (b); i < _b; ++i) #define fort(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define ford(i, a, b) for (int i = (a), _b = (b); i >= _b; --i) #define fi first #define se second #define pb push_back #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define add(x, y) (((x) + (y)) % MOD) #define sub(x, y) (((x) - (y) + MOD) % MOD) #define mul(x, y) (1LL * (x) * (y) % MOD) using namespace std; using ll = long long; template<class A, class B> bool maxi(A &a, const B &b) {return (a < b) ? (a = b, true):false;}; template<class A, class B> bool mini(A &a, const B &b) {return (a > b) ? (a = b, true):false;}; typedef long double ld; typedef unsigned long long ull; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef vector<vii> vvii; const int maxN = 105, MOD = 1e9 + 2003, base = 2003; int n; char s[maxN]; set<int> numbers; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> s + 1; n = strlen(s + 1); for (int i = 1; i <= n;) { while (i <= n && !isdigit(s[i])) ++i; if (i > n) break; int x = 0; while (i <= n && isdigit(s[i])) x = add(mul(x, base), s[i++]); numbers.insert(x); } cout << sz(numbers) << '\n'; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:38:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |     cin >> s + 1;
      |            ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...