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 生活100日目

Posted at

前回

#100日目
今回は、灰色の問題を2問ときました。

|問題|難易度|自力で解けた|かかった時間|
|:-:|:-:|:-:|---|---|
|エイシング プログラミング コンテスト 2020|C|✕|25分41秒|
|AtCoder Regular Contest 105|B|✕|40分21秒|

##エイシング プログラミング コンテスト 2020_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;

int main(){
    int n;
    cin >> n;
    vector<int> f(n,0);
    for(int x = 1;x*x <= n;x++){
        for(int y = 1;y*y <= n;y++){
            for(int z = 1;z*z <= n;z++){
                int t = x*x + y*y + z*z + x*y + y*z + z*x;
                if(t <= n)f[t-1]++;
            }
        }
    }
    rep(i,n){
        cout << f[i] << endl;
    }
}

解くのにかかった時間:25分41秒
感想:ifで条件をつけないと実行時エラーが発生した。

##AtCoder Regular Contest 105_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(){
    int n;
    cin >> n;
    ll res = 0;
    rep(i,n){
        ll a;
        cin >> a;
        res = gcd(res,a);
    }
    cout << res << endl;
}

解くのにかかった時間:40分21秒
感想:ユークリッド互除法を復習してみるか…

###最後に
茶色に近い問題も簡単に解けるようにしておきたい

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?