QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#495221#9156. 百万富翁ActuctCompile Error//C++14808b2024-07-27 19:32:202024-07-27 19:32:20

Judging History

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

  • [2024-07-27 19:32:20]
  • 评测
  • [2024-07-27 19:32:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define N 1000000
#define INF 0x3f3f3f3f3f3f3fll
#define ll long long
ll dp[N+1][10],pre[N+1][10],v;
inline ll calc(ll n,ll k){
	static ll q,r;q=n/k,r=n%k;
	if(r==0)return q*(k*(k-1)/2);
	if(q+1>=k-r)return (q+1)*(k*(k-1)/2)-(k-r)*(k-1);
	return 0;
}
int main(){
	for(ll i=1;i<=N;++i)dp[i][1]=i*(i-1)/2;
	for(ll i=2;i<=8;++i){
		for(int j=1;j<=N;++j)dp[j][i]=INF;
		for(ll j=1001;j<=N;++j){
			for(ll k=2;k<=30;++k){
				v=dp[(j-1)/k+1][i-1]+calc(j,k);
				if(v<dp[j][i])dp[j][i]=v,pre[j][i]=k;
			}
		}
	}
	printf("%lld\n",dp[N][8]);
	int pos=N;
	for(int i=8;i>=2;--i){
		printf("%d %lld (%lld)\n",pos,pre[pos][i],calc(pos,pre[pos][i]));
		pos=(pos-1)/pre[pos][i]+1;
	}
	printf("%d %d (%lld)\n",pos,pos,pos*(pos-1)/2);
	return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:30:27: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘int’ [-Wformat=]
   30 |         printf("%d %d (%lld)\n",pos,pos,pos*(pos-1)/2);
      |                        ~~~^             ~~~~~~~~~~~~~
      |                           |                        |
      |                           long long int            int
      |                        %d
/usr/bin/ld: /tmp/ccF795Gj.o: in function `main':
answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/ccka8Owm.o:implementer.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccka8Owm.o: in function `main':
implementer.cpp:(.text.startup+0x1df): undefined reference to `richest(int, int, int)'
collect2: error: ld returned 1 exit status