Language: C++

#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
 
//#define int ll
//#define int long long
 
signed main()
{
 int a, b, k; cin >> a >> b >> k;
  int cnt = 0;
  vi v1(0,0);
  int whi = max(a,b);
  for(int i =1; i < whi; ++i){
    if(a%i == 0&&b%i == 0){
     v1.PB(i);
      ++cnt;
    }
  }
/*for(int i = 1; i <= whi; ++i){
  cout << a%i;
  cout << b%i << endl;
}*/
  
//  REP(i, cnt){cout << v1[i] << endl;}
  sort(ALL(v1));
  reverse(v1.begin(),v1.end());
  cout << v1[k];
 
  return 0;
}
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
 
//#define int ll
//#define int long long
 
signed main()
{
 int a, b, k; cin >> a >> b >> k;
  int cnt = 0;
  vi v1(0,0);
  int whi = max(a,b);
  for(int i =1; i < whi; ++i){
    if(a%i == 0&&b%i == 0){
     v1.PB(i);
      ++cnt;
    }
  }
/*for(int i = 1; i <= whi; ++i){
  cout << a%i;
  cout << b%i << endl;
}*/
  
//  REP(i, cnt){cout << v1[i] << endl;}
  sort(ALL(v1));
  reverse(v1.begin(),v1.end());
  cout << v1[k];

  return 0;
}
提出情報

Compiler output:
a.cc:120:30: error: redefinition of 'template<class T> bool amax(T&, const T&)'
  120 | template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
      |                              ^~~~
a.cc:37:30: note: 'template<class T> bool amax(T&, const T&)' previously declared here
   37 | template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
      |                              ^~~~
a.cc:121:30: error: redefinition of 'template<class T> bool amin(T&, const T&)'
  121 | template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
      |                              ^~~~
a.cc:38:30: note: 'template<class T> bool amin(T&, const T&)' previously declared here
   38 | template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
      |                              ^~~~
a.cc:124:5: error: redefinition of 'int gcd(int, int)'
  124 | int gcd(int a,int b){return b?gcd(b,a%b):a;}
      |     ^~~
a.cc:41:5: note: 'int gcd(int, int)' previously defined here
   41 | int gcd(int a,int b){return b?gcd(b,a%b):a;}
      |     ^~~
a.cc:127:8: error: redefinition of 'struct aaa'
  127 | struct aaa{
      |        ^~~
a.cc:44:8: note: previous definition of 'struct aaa'
   44 | struct aaa{
      |        ^~~
a.cc:131:2: error: conflicting declaration 'int aaaaaaa'
  131 | }aaaaaaa;
      |  ^~~~~~~
a.cc:48:2: note: previous declaration as 'aaa aaaaaaa'
   48 | }aaaaaaa;
      |  ^~~~~~~
a.cc:134:11: error: redefinition of 'const int INF'
  134 | const int INF = 1001001001;
      |           ^~~
a.cc:51:11: note: 'const int INF' previously defined here
   51 | const int INF = 1001001001;
      |           ^~~
a.cc:135:10: error: redefinition of 'const ll LINF'
  135 | const ll LINF = 1001001001001001001ll;
      |          ^~~~
a.cc:52:10: note: 'const ll LINF' previously defined here
   52 | const ll LINF = 1001001001001001001ll;
      |          ^~~~
a.cc:136:11: error: redefinition of 'const int MOD'
  136 | const int MOD = 1e9 + 7; //10^9
      |           ^~~
a.cc:53:11: note: 'const int MOD' previously defined here
   53 | const int MOD = 1e9 + 7; //10^9
      |           ^~~
a.cc:137:10: error: redefinition of 'const db EPS'
  137 | const db EPS = 1e-9;
      |          ^~~
a.cc:54:10: note: 'const db EPS' previously defined here
   54 | const db EPS = 1e-9;
      |          ^~~
a.cc:138:11: error: redefinition of 'const int dx []'
  138 | const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
      |           ^~
a.cc:55:11: note: 'const int dx [8]' previously defined here
   55 | const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
      |           ^~
a.cc:138:47: error: redefinition of 'const int dy []'
  138 | const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
      |                                               ^~
a.cc:55:47: note: 'const int dy [8]' previously defined here
   55 | const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
      |                                               ^~
a.cc:143:8: error: redefinition of 'int main()'
  143 | signed main()
      |        ^~~~
a.cc:60:8: note: 'int main()' previously defined here
   60 | signed main()
      |        ^~~~
a.cc:167:1: error: '\U000063d0\U000051fa\U000060c5\U00005831' does not name a type
  167 | 提出情報
      | ^~~~~~~~