結果

問題 No.1083 余りの余り
ユーザー snrnsidy
提出日時 2021-10-05 01:52:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 97 ms / 3,000 ms
コード長 517 bytes
コンパイル時間 2,076 ms
コンパイル使用メモリ 199,220 KB
最終ジャッジ日時 2025-01-24 20:40:23
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(void) 
{
	cin.tie(0);
	ios::sync_with_stdio(false);

  int n,k;
  long long int t;
  vector <long long int> a;
  long long int res = 0;

  cin >> n >> k;

  for(int i=0;i<n;i++)
  {
    cin >> t;
    a.push_back(t);
  }

  sort(a.rbegin(),a.rend());

  for(int i=0;i<(1<<(n-1));i++)
  {
    long long int X = k;
    for(int j=0;j<n-1;j++)
    {
      if((i&(1<<j))) X%=a[j];
    }
    X%=a[n-1];
    res = max(res,X);
  }

  cout << res << '\n';

  return 0;
}
0