QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#379250#8565. Basic Bloomsucup-team191#AC ✓1231ms17384kbC++231.9kb2024-04-06 16:46:102024-04-06 16:46:11

Judging History

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

  • [2024-04-06 16:46:11]
  • 评测
  • 测评结果:AC
  • 用时:1231ms
  • 内存:17384kb
  • [2024-04-06 16:46:10]
  • 提交

answer

#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using ld=long double;
using pii=pair<int,int>;
using vi=vector<int>;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)

const int N=1000010,MOD=998244353;
const char en='\n';
const ll LLINF=1ll<<60;

int add1(int a,int k,int j)
{
	return (a*1ll*k+j)%MOD;
}

pair<int,ld> add2(pair<int,ld> a,int k,int j)
{
	a.y*=k;
	a.y+=j*pow(1.L/16,a.x);
	while (a.y>=16)
	{
		++a.x;
		a.y/=16;
	}
	return a;
}

int t;
pair<int,ld> va[30][30];
int rva[30][30];
bool allo[30][30];
vi val;
vl pref;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	const int B=16;
	for (int i=2;i<=B;++i) for (int j=1;j<i;++j) va[i][j]={0,j},rva[i][j]=j,allo[i][j]=1;
	allo[9][4]=0;
	allo[9][8]=0;
	allo[4][3]=0;
	allo[8][7]=0;
	allo[16][5]=0;
	allo[16][10]=0;
	allo[16][15]=0;
	while (val.size()<N)
	{
		//cout<<val.size()<<endl;
		pair<int,ld> mi=va[2][1];
		int rvaa=rva[2][1];
		pii kak={2,1};
		for (int i=2;i<=B;++i) for (int j=1;j<i;++j) if (allo[i][j] && va[i][j]<mi)
		{
			mi=va[i][j];
			rvaa=rva[i][j];
			kak={i,j};
		}
		for (int i=2;i<=B;++i) for (int j=1;j<i;++j) if (allo[i][j])
		{
			if ((va[i][j]==mi)!=(rva[i][j]==rvaa))
			{
				cout<<i<<' '<<j<<en<<va[i][j].x<<' '<<va[i][j].y<<' '<<rva[i][j]<<en;
				cout<<kak.x<<' '<<kak.y<<en<<mi.x<<' '<<mi.y<<' '<<rvaa<<en;
				exit(0);
			}
			if (va[i][j]==mi)
			{
				//cout<<i<<' '<<j<<' '<<mi.x<<' '<<mi.y<<' '<<rvaa<<' '<<rva[i][j]<<endl;
				va[i][j]=add2(va[i][j],i,j);
				rva[i][j]=add1(rva[i][j],i,j);
			}
		}
		val.pb(rvaa);
		//if (val.size()<20) cout<<"V"<<val.back()<<endl;
	}
	//cout<<en;
	pref.pb(0);
	for (auto x: val) pref.pb(pref.back()+x);
	cin>>t;
	while (t--)
	{
		int l,r;
		cin>>l>>r;
		--l;
		cout<<(pref[r]-pref[l])%MOD<<en;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1054ms
memory: 15732kb

input:

3
1 2
1 10
15 2000

output:

3
55
736374621

result:

ok 3 number(s): "3 55 736374621"

Test #2:

score: 0
Accepted
time: 1091ms
memory: 17384kb

input:

100000
26 99975
57 99944
28 99973
62 99939
71 99930
25 99976
53 99948
60 99941
73 99928
72 99929
30 99971
7 99994
3 99998
35 99966
73 99928
68 99933
83 99918
37 99964
63 99938
17 99984
34 99967
74 99927
6 99995
3 99998
23 99978
91 99910
39 99962
85 99916
82 99919
17 99984
61 99940
31 99970
44 99957
...

output:

957904590
358359691
31524403
519690359
208321031
477204717
835715447
186583689
847423322
760952087
25753603
241428916
832623523
232679133
847423322
11425904
640652773
663756612
767901835
356898792
503593019
495288401
265039242
832623523
793754988
389398856
758928836
349243444
158978749
356898792
873...

result:

ok 100000 numbers

Test #3:

score: 0
Accepted
time: 1231ms
memory: 16432kb

input:

1000000
561662 731870
560627 798415
497930 613164
210084 556894
479283 902738
271881 288854
467622 971733
55854 157477
310152 415183
146385 874852
140599 526659
438420 629148
733746 924626
84146 436790
275793 457537
466464 541539
661070 696519
534866 688272
190259 412401
206392 354525
2344 217676
51...

output:

387682849
91353801
759238022
175113502
143631299
488887729
201615869
359127675
954541571
806609754
254074751
589282709
523407089
298821716
593042756
268635027
495659009
878948937
741148909
716887807
31798813
425888650
765930054
831198164
372500280
694558761
918178838
919393601
661100143
134966024
37...

result:

ok 1000000 numbers

Extra Test:

score: 0
Extra Test Passed