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 1 year has passed since last update.

【メモ】AtCoderで使えそうなSTL

0
Last updated at Posted at 2024-08-02
  • gcd, lcm:最大公約数、最小公倍数を返す関数(コメント参照)
  • count:配列内の指定した区間内に含まれる、指定した要素の個数を返す関数
  • find:配列内の指定した区間内で、指定した要素を保持する最初のイテレータを返す関数
#include <bits/stdc++.h>
using namespace std;

int main() {
  cout << gcd(8, 12) << endl; // -> 4
  cout << lcm(8, 12) << endl; // -> 24
  
  vector<int> a = { 1, 2, 2, 1, 1 };
  cout << count(a.begin(), a.end(), 1) << endl; // -> 3
  
  int pos = find(a.begin(), a.end(), 2) - a.begin();
  cout << pos << endl; // -> 1
}
0
0
2

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?