AtCoder Beginner Contest 233

##[A - 10yen Stamp](https://atcoder.jp/contests/abc233/tasks/abc233_a)

O(N)
シミュレートしました。

```C++:C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main() {
    int x, y;
    cin >> x >> y;

    int res=0;
    rep(i, 500){
        if(x+i*10>=y){
            res = i;
            break;
        }
    }
    cout << res << endl;

    return 0;
}
```

##[B - A Reverse](https://atcoder.jp/contests/abc233/tasks/abc233_b)

O(N)

```C++:C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main() {
    int l, r;
    cin >> l >> r;
    l--;
    r--;

    string s;
    cin >> s;

    string t = s.substr(l, r-l+1);
    reverse(t.begin(), t.end());

    int cnt=0;
    for(int i=l; i<=r; i++){
        s[i] = t[cnt];
        cnt++;
    } 
    cout << s << endl;

    return 0;
}
```

##[C - Product](https://atcoder.jp/contests/abc233/tasks/abc233_c)

O(N)
掛け算を行うとオーバーフローが起きると考えました。
割り算で行なっています。

```C++:C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

ll res=0;

void dfs(ll X, vector<vector<ll>> a, int cnt){
    if(a.size()<=cnt){
        if(X==1) res++;
        return;
    }

    int n = a[cnt].size();

    rep(i, n){
        if(X%a[cnt][i] == 0) dfs(X/a[cnt][i], a, cnt+1);
    }
}

int main() {
    ll N, X;
    cin >> N >> X;

    vector<vector<ll>> a(N);
    rep(i, N){
        int l;
        cin >> l;

        a[i].resize(l);
        rep(j, l) cin >> a[i][j];
    }

    dfs(X, a, 0);

    cout << res << endl;

    return 0;
}
```

##[D - Count Interval](https://atcoder.jp/contests/abc233/tasks/abc233_d)

O(N)

```C++:C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }
 
int main() {
    ll N, K;
    cin >> N >> K;
 
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> B(N+1);
    rep(i, N) B[i+1] = A[i] + B[i];
 
    ll res=0;
    map<ll, ll> mp;
    for(int r=1; r<N+1; r++){
        mp[B[r-1]]++;
        res += mp[B[r]-K];
    }
    cout << res << endl;
 
    return 0;
}
```