結果
| 問題 |
No.473 和と積の和
|
| コンテスト | |
| ユーザー |
rickytheta
|
| 提出日時 | 2016-12-23 00:28:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,223 bytes |
| コンパイル時間 | 1,569 ms |
| コンパイル使用メモリ | 170,152 KB |
| 実行使用メモリ | 288,044 KB |
| 最終ジャッジ日時 | 2024-12-16 02:44:46 |
| 合計ジャッジ時間 | 21,275 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 41 TLE * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))
// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;
struct myhash{
size_t operator()(const vi &v) const {
hash<int> hsh;
size_t ret=0;
for(int x:v){
ret ^= hsh(x);
ret = ret ^ (ret<<13);
ret = ret ^ (ret>>17);
ret = ret ^ (ret<<5);
}
return ret;
}
};
int main(){
int n;
int x;
cin>>n>>x;
if(n>=30){
puts("0");
return 0;
}
x++;
typedef unordered_set<vi,myhash> ss;
// factorize x with n numbers
ss S;
S.insert(vi(n,1));
for(int p=2;p*p<=x;p++){
while(x%p==0){
x/=p;
ss nxt;
for(const vi &X : S){
REP(i,n){
vi add(n,0);
int nw = X[i]*p;
int it = 0;
REP(j,n){
while(it==i)it++;
if(it<n && X[it]<nw)add[j]=X[it++];
else{
add[j]=nw;
nw = (1<<30) + 252;
}
}
nxt.insert(add);
}
}
swap(S,nxt);
}
}
if(x!=1){
ss nxt;
for(const vi &X : S){
REP(i,n){
vi add(n,0);
int nw = X[i]*x;
int it = 0;
REP(j,n){
while(it==i)it++;
if(it<n && X[it]<nw)add[j]=X[it++];
else{
add[j]=nw;
nw = (1<<30) + 252;
}
}
nxt.insert(add);
}
}
swap(S,nxt);
}
int ans = 0;
for(const vi &X : S){
if(X[0]!=1)ans++;
}
printf("%d\n",ans);
return 0;
}
rickytheta