답안 #383622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
383622 2021-03-30T12:05:22 Z nguyen31hoang08minh2003 Sifra (COCI21_sifra) C++14
50 / 50
1 ms 364 KB
#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

Main.cpp: In function 'int main()':
Main.cpp:38:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |     cin >> s + 1;
      |            ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct