QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#239570#7688. Alea Iacta Estucup-team197#WA 217ms63056kbC++141.4kb2023-11-04 21:26:202023-11-04 21:26:21

Judging History

你现在查看的是最新测评结果

  • [2023-11-04 21:26:21]
  • 评测
  • 测评结果:WA
  • 用时:217ms
  • 内存:63056kb
  • [2023-11-04 21:26:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int N=1e6+5;
const int iu=1e6;
vector<int>pf[N];
ll n,m;
vector<ll>v;
void gen(vector<pair<ll,ll> >&g,int id,ll cur){
	if(id==g.size()){
		v.push_back(cur);
		return;
	}
	for(int i=0; i<g[id].fi ;i++){
		ll dx=i*g[id].se;
		gen(g,id+1,cur+dx);
	}
}
void solve(){
	cin >> n >> m;
	if(n>m) swap(n,m);
	ll xs=n;
	for(ll s=n+1; s<=m ;s++){
		if(s*s>n*m) break;
		if(n*m%s==0) xs=s;
	}
	vector<pair<ll,ll> >gn;
	{
		ll step=1;
		for(auto c:pf[n]){
			gn.push_back({c,step});
			step*=c;
		}
	}
	{
		ll step=1;
		for(auto c:pf[m]){
			gn.push_back({c,step});
			step*=c;
		}
	}
	vector<pair<ll,ll> >gl,gr;
	for(auto c:gn){
		if(xs%c.fi==0){
			xs/=c.fi;
			gl.push_back(c);
		}
		else gr.push_back(c);
	}
	v.clear();
	//for(auto c:) cout << c.fi << ' ' << c.se << endl;
	gen(gl,0,0);
	cout << v.size() << ' ';
	for(auto c:v) cout << c+1 << ' ';
	cout << '\n';
	v.clear();
	gen(gr,0,0);
	cout << v.size() << ' ';
	for(auto c:v) cout << c+1 << ' ';
	cout << '\n';
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	for(int i=2; i<=iu ;i++){
		if(!pf[i].empty()) continue;
		for(int j=i; j<=iu ;j+=i){
			int z=j;
			while(z%i==0){
				z/=i;
				pf[j].push_back(i);
			}
		}
	}
	int t;cin >> t;
	while(t--) solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 216ms
memory: 62748kb

input:

3
2 8
1 9
2 9

output:

4 1 2 2 3 
4 1 5 3 7 
3 1 2 3 
3 1 4 7 
3 1 2 3 
6 1 4 7 2 5 8 

result:

ok Correct. (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 217ms
memory: 63056kb

input:

1
40013 40013

output:

40013 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...

result:

wrong answer Same as input (test case 1)