結果

問題 No.473 和と積の和
ユーザー tails
提出日時 2016-12-23 03:42:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 700 bytes
コンパイル時間 1,923 ms
コンパイル使用メモリ 181,112 KB
実行使用メモリ 670,336 KB
最終ジャッジ日時 2024-12-16 03:03:49
合計ジャッジ時間 30,951 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 MLE * 2
other AC * 35 TLE * 6 MLE * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

main(){
	int n,x;
	scanf("%d%d",&n,&x);
	++x;
	vector<int> v;
	for(int i=2;i*i<=x;){
		if(x%i==0){
			v.push_back(i);
			x/=i;
		}else{
			++i;
		}
	}
	v.push_back(x);
	int r=0;
	if(v.size()>=n){
		multiset<int> m;
		for(int i=0;i<n;++i){
			m.insert(1);
		}
		set<multiset<int>> s1,s2;
		s1.insert(m);
		for(int vi:v){
			for(multiset<int> const& m1:s1){
				int l=0;
				for(int a:m1){
					if(a!=l){
						l=a;
						multiset<int> m2=m1;
						m2.erase(m2.find(a));
						m2.insert(a*vi);
						s2.insert(m2);
					}
				}
			}
			s1.swap(s2);s2.clear();
		}
		for(multiset<int> const& m1:s1){
			r+=m1.find(1)==m1.end();
		}
	}
	printf("%d\n",r);
}
0