QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#89325#4129. 淘金Purslane30 33ms5460kbC++141.9kb2023-03-19 19:46:132023-03-19 19:46:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-19 19:46:15]
  • 评测
  • 测评结果:30
  • 用时:33ms
  • 内存:5460kb
  • [2023-03-19 19:46:13]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long 
#define ffor(i,a,b) for(int i=(a);i<=(b);i++)
#define roff(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
const int MAXN=20,MOD=1e9+7;
struct INFO {int k,op,sum;}; //op 是否有限制 sum 个数 k 乘积 
map<int,int> f; int a[MAXN],tot,ans,n,k,v[100000];
struct Item {__int128 ziji,chengji;int id;};
bool operator <(Item a,Item b) {return a.chengji<b.chengji;}
signed main() {
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>k;
	int N=n,len=0;
	while(N) a[++len]=N%10,N/=10;
	vector<INFO> vc;
	vc.push_back({1,1,1});
	roff(i,len,1) {
		vector<INFO> nw;
		map<pair<int,int>,int> mp;
		for(auto info:vc) {
			int k=info.k,op=info.op,sum=info.sum;
			if(op) {
				ffor(j,1,a[i]) {
					int K=k*j,OP=op&(j==a[len]);
					if(K<=n) mp[{K,OP}]+=sum;
				}
			}
			else {
				ffor(j,1,9) {
					int K=k*j,Op=0;
					if(K<=n) mp[{K,0}]+=sum;	
				}
			}
		}
		for(auto info:mp) nw.push_back({info.first.first,info.first.second,info.second});
		vc=nw;
	}
	for(auto pr:vc) f[pr.k]+=pr.sum;
	vc.clear();
	vc.push_back({1,0,1});
	ffor(i,1,len-1) {
		vector<INFO> nw;
		map<pair<int,int>,int> mp;
		for(auto info:vc) {
			int k=info.k,op=info.op,sum=info.sum;
			ffor(j,1,9) {
				int K=k*j,Op=0;
				if(K<=n) mp[{K,0}]+=sum;	
			}
		}
		for(auto info:mp) nw.push_back({info.first.first,info.first.second,info.second});
		vc=nw;	
		for(auto pr:vc) f[pr.k]+=pr.sum;
	}
	vector<int> Vc;
	for(auto pr:f) Vc.push_back(pr.second);
	sort(Vc.begin(),Vc.end(),[](int A,int B) {return A>B;});
	for(auto u:Vc) v[++tot]=u;
	priority_queue <Item> q;
	ffor(i,1,tot) q.push({v[i],(__int128)v[i]*v[1],1});
	__int128 ans=0;
	ffor(i,1,k) {
		__int128 chengji=q.top().chengji,ziji=q.top().ziji; int id=q.top().id;
		q.pop(); ans+=chengji;
		if(id!=tot) {
			++id; q.push({ziji,(__int128)ziji*v[id],id});	
		}
	}
	int res=(int)(ans%(1000000000+7));
	cout<<res;
	return 0;
}


詳細信息

Test #1:

score: 0
Wrong Answer
time: 21ms
memory: 5144kb

input:

993643210231 1

output:

119423588

result:

wrong answer 1st lines differ - expected: '754915436', found: '119423588'

Test #2:

score: 10
Accepted
time: 33ms
memory: 5432kb

input:

1000000000000 99654

output:

252380303

result:

ok single line: '252380303'

Test #3:

score: 0
Wrong Answer
time: 20ms
memory: 5108kb

input:

987656542346 1

output:

185849893

result:

wrong answer 1st lines differ - expected: '606590188', found: '185849893'

Test #4:

score: 10
Accepted
time: 2ms
memory: 3444kb

input:

908 1115

output:

218202

result:

ok single line: '218202'

Test #5:

score: 10
Accepted
time: 26ms
memory: 5460kb

input:

1000000000000 63549

output:

433656825

result:

ok single line: '433656825'

Test #6:

score: 0
Wrong Answer
time: 9ms
memory: 3584kb

input:

884908 89456

output:

669324129

result:

wrong answer 1st lines differ - expected: '621252198', found: '669324129'

Test #7:

score: 0
Wrong Answer
time: 10ms
memory: 3548kb

input:

971257 66548

output:

34525863

result:

wrong answer 1st lines differ - expected: '681002372', found: '34525863'

Test #8:

score: 0
Wrong Answer
time: 31ms
memory: 5244kb

input:

954336460239 96432

output:

193552771

result:

wrong answer 1st lines differ - expected: '522616255', found: '193552771'

Test #9:

score: 0
Wrong Answer
time: 1ms
memory: 3420kb

input:

990 12250

output:

658549

result:

wrong answer 1st lines differ - expected: '656100', found: '658549'

Test #10:

score: 0
Wrong Answer
time: 28ms
memory: 5140kb

input:

993216540324 89654

output:

400469100

result:

wrong answer 1st lines differ - expected: '372273878', found: '400469100'