0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AtCoder 生活 98日目

Last updated at Posted at 2020-10-17

前回

#98日目
今回はABC177のA〜C問題をときました。

|問題|難易度|自力で解けた|かかった時間|
|:-:|:-:|:-:|---|---|
|ABC177|A|◯|5分18秒|
|ABC177|B|◯|23分10秒|
|ABC177|C|✕|68分1秒|

##ABC177

###A


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;

int main(){
    int d,t,s;
    cin >> d >> t >> s;
    t *= s;
    if(d <= t)cout << "Yes" << endl;
    else cout << "No" << endl;
}

解くのにかかった時間:5分18秒

###B


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;

int main(){
    string s,t;
    cin >> s >> t;
    int ls = s.size();
    int lt = t.size();
    int ans = lt;
    rep(i,ls-lt+1){
        int cnt = 0;
        rep(j,lt){
            if(s[i+j] != t[j])cnt++;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}

解くのにかかった時間:23分10秒

###C


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;
const int MOD = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    ll sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
        sum %= MOD;
    }
    ll ans = 0;
    rep(i,n){
        sum -= a[i];
        if(sum < 0) sum += MOD;
        ans += a[i] * sum;
        ans %= MOD;
    }
    cout << ans << endl;
}

解くのにかかった時間:68分1秒
感想:なんか全探索の計算がうまくできない

###最後に
普通の計算トレーニングをしなければいけない気がする

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?