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.

B - Orthogonality, A - Three-letter acronym, C - Monsters Battle Royale

Last updated at Posted at 2021-02-16

2021/2/15
くじかつ精進内容

##B - Orthogonality

O(N)
問題の内容は、A[i]*B[i]の合計は0か判定してください。

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; }
const long long INF = 1LL << 60;
 
int main() {
    int n;
    cin >> n;
 
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
 
    ll res = 0;
    rep(i, n){
        res += a[i] * b[i];
    }
    if(res == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
 
    return 0;
}

##A - Three-letter acronym

o(1)
問題は、先頭の文字列を大文字に変換し繋ぎ合わせて出力せよ。
pythonの大文字への変換メソッドは「upper」です。

python
S1, S2, S3 = list(map(str, input().split()))
print(S1.upper()[0] + S2.upper()[0] + S3.upper()[0])

##C - Monsters Battle Royale

O(N)
最大公約数を求める問題です。

python
import math
from functools import reduce
 
N = int(input())
A = list(map(int, input().split()))
 
res = reduce(math.gcd, A)
print(res)
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?