結果
| 問題 |
No.941 商とあまり
|
| コンテスト | |
| ユーザー |
sigma425
|
| 提出日時 | 2019-12-04 01:06:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,906 bytes |
| コンパイル時間 | 2,629 ms |
| コンパイル使用メモリ | 206,488 KB |
| 最終ジャッジ日時 | 2025-01-08 07:25:28 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 WA * 1 |
| other | AC * 71 WA * 33 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
o<<"{";
for(const T& v:vc) o<<v<<",";
o<<"}";
return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }
#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif
int main(){
cin.tie(0);
ios::sync_with_stdio(false); //DON'T USE scanf/printf/puts !!
cout << fixed << setprecision(20);
int N,X; cin >> N >> X;
ll MN = 1;
V<int> a(N); rep(i,N) cin >> a[i];
const ll inf = 1e10;
V<bool> res(X+1);
auto ANSWER = [&](V<bool> res){
string s(X,'0');
rep(i,X) if(res[i+1]) s[i] = '1';
cout << s << endl;
exit(0);
};
{
ll A = 1;
rep(i,N){
A *= a[i] + 1;
chmin(A,inf);
}
A--;
if(A > X){
ANSWER(res);
}
MN = A;
}
res[MN] = true;
if(N == 1) ANSWER(res);
V<int> vx;
rep(b,1<<N){
int v = 1;
rep(i,N) if((b>>i)&1) v *= a[i]+1;
vx.pb(v);
}
sort(all(vx));vx.erase(unique(all(vx)),vx.end());
for(int x: vx){
int y = (MN+1)/x;
if(x>y) break;
if(x == 1) continue;
x--,y--;
show(x);show(y);
int g = __gcd(x,y);
rep1(i,y/g+1){
bool ibreak = false;
rep1(j,x/g+1){
int v = x*y+x*i+y*j;
if(v > X){
if(j == 1) ibreak = true;
break;
}
res[v] = true;
}
if(ibreak) break;
}
for(int i=x*y+x+y+x*y;i<=X;i+=g) res[i] = true;
}
ANSWER(res);
}
sigma425