結果

問題 No.1083 余りの余り
コンテスト
ユーザー 👑 kmjp
提出日時 2020-06-19 22:15:36
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 1,007 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,471 ms
コンパイル使用メモリ 216,772 KB
実行使用メモリ 67,072 KB
最終ジャッジ日時 2026-06-10 20:12:58
合計ジャッジ時間 10,340 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample TLE * 1 -- * 2
other -- * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:66,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:62,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
                 from main.cpp:1:
In function 'constexpr void std::__advance(_InputIterator&, _Distance, input_iterator_tag) [with _InputIterator = __detail::_Node_iterator<int, true, false>; _Distance = long int]',
    inlined from 'constexpr void std::advance(_InputIterator&, _Distance) [with _InputIterator = __detail::_Node_iterator<int, true, false>; _Distance = long int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_iterator_base_funcs.h:226:21,
    inlined from 'constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type) [with _BidirectionalIterator = __detail::_Node_iterator<int, true, false>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_iterator_base_funcs.h:252:19,
    inlined from 'void solve()' at main.cpp:32:13:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_iterator_base_funcs.h:164:7: warning: iteration 9223372036854775807 invokes undefined behavior [-Waggressive-loop-optimizations]
  164 |       while (__n--)
      |       ^~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_iterator_base_funcs.h:164:7: note: within this loop

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K,A[20];
unordered_set<int> S[1<<20];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) cin>>A[i];
	S[0].insert(K);
	int mask;
	FOR(mask,1<<N) {
		FOR(i,N) if((mask&(1<<i))==0) {
			FORR(s,S[mask]) S[mask|(1<<i)].insert(s%A[i]);
		}
		S[mask].clear();
	}
	auto it=S[(1<<N)-1].end();
	cout<<*prev(it)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0