結果

問題 No.1083 余りの余り
ユーザー 👑 kmjpkmjp
提出日時 2020-06-19 22:15:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,007 bytes
コンパイル時間 2,308 ms
コンパイル使用メモリ 205,648 KB
実行使用メモリ 69,780 KB
最終ジャッジ日時 2023-09-16 14:34:40
合計ジャッジ時間 10,608 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/stl_algobase.h:66,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/specfun.h:45,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/cmath:1935,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:41,
         次から読み込み:  main.cpp:1:
関数 ‘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 /usr/local/gcc7/include/c++/12.2.0/bits/stl_iterator_base_funcs.h:222:21,
    inlined from ‘constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type) [with _BidirectionalIterator = __detail::_Node_iterator<int, true, false>]’ at /usr/local/gcc7/include/c++/12.2.0/bits/stl_iterator_base_funcs.h:248:19,
    inlined from ‘void solve()’ at main.cpp:32:13:
/usr/local/gcc7/include/c++/12.2.0/bits/stl_iterator_base_funcs.h:161:7: 警告: iteration 9223372036854775807 invokes undefined behavior [-Waggressive-loop-optimizations]
  161 |       while (__n--)
      |       ^~~~~
/usr/local/gcc7/include/c++/12.2.0/bits/stl_iterator_base_funcs.h:161:7: 備考: within this loop

ソースコード

diff #

#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