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.

競プロ挑戦日記day2【ABC176】

Posted at

#A問題

  • 所要時間:8分
  • 一発AC

###解答

ABC176_A
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    int ans = 0;
    int a = n / x;
    ans = a * t;
    if(n % x != 0){
        ans += t;
    }
    cout << ans << endl;
}

#B問題

  • 所要時間:20分
  • 一発AC
  • string 型でデータを取得するのがミソ

###解答

ABC176_B
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int sum = 0;
    string s;
    cin >> s;
    for(char x : s){
        //i++;
        int a = x - '0';
        sum += a;
      //cout << i << " " << sum << " " << a << endl;
    }
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

#C問題

  • 答えがint型だと収まらないのに気づかなかった
  • int型からlong long int型に変更するとACした(テスト後)

##問題文
###解答

ABC176_C
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, sum = 0;
    cin >> n;
    vector<int> tall(n);
    for (int i = 0; i < n; i++)
    {
        cin >> tall.at(i);
    }
    for (int i = 0; i < n - 1; i++)
    {
        int b;
        b = tall.at(i + 1) - tall.at(i);
        if (b < 0){
            tall.at(i + 1) = tall.at(i);
            sum += -b;
        }
    }
    cout << sum << endl;
}

#Rate
10→20になりました!
今回もC問題が惜しかった!
残念!
入茶目指して頑張るぞ!

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?