QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#108836#6510. Best Carry Player 3RiceShower#AC ✓137ms1760kbC++239.6kb2023-05-26 19:00:552023-05-26 19:01:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-26 19:01:00]
  • 评测
  • 测评结果:AC
  • 用时:137ms
  • 内存:1760kb
  • [2023-05-26 19:00:55]
  • 提交

answer

// dottle bot
#ifndef ONLINE_JUDGE
#define DEBUG
#endif
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <assert.h>
#include <math.h>
#include <set>
#define nln puts("")
#define od(x) printf("%d",x)
#define odb(x) printf("%d ",x)
#define odl(x) printf("%d\n",x)
#define odp(x,y) printf("%d %d\n",x,y)
#define ol(x) puts("")
#define old(x) printf("%lld",x)
#define oldb(x) printf("%lld ",x)
#define oldl(x) printf("%lld\n",x)
#define oldp(x,y) printf("%lld %lld\n",x,y)
#define rg(x) for(int i=1;i<=(x);i++){
#define rg_(i,x) for(int i=1;i<=(x);i++){
#define fe(u) for(int i=h[u];i;i=e[i].nxt){int v=e[i].v;
#define gr }
#define rrg(x) for(int i=0;i<(x);i++){
#define rdln(a) a[i]=read();
#define rdln0(a,x) rrg(x) rdln(a) gr
#define rdln1(a,x) rg(x) rdln(a) gr
template<typename T>
void print(T x){}
template<>
void print<int>(int x){od(x);}
template<>
void print<const int>(const int x){od(x);}
template<>
void print<long long>(long long x){old(x);}
template<>
void print<const long long>(const long long x){old(x);}
template<>
void print<char>(char x){putchar(x);}
template<>
void print<const char>(const char x){putchar(x);}
template<>
void print<double>(double x){printf("%.12lf",x);}
template<typename T,typename... qwq>
void print(T x,qwq ...args)
{
	print(x);
	print(args...);
}
#ifdef DEBUG
template<typename T>
void debug(T x){}
template<>
void debug<int>(int x){od(x);}
template<>
void debug<const int>(const int x){od(x);}
template<>
void debug<long long>(long long x){old(x);}
template<>
void debug<const long long>(const long long x){old(x);}
template<>
void debug<char>(char x){putchar(x);}
template<>
void debug<const char>(const char x){putchar(x);}
template<>
void debug<double>(double x){printf("%.12lf",x);}
template<typename T,typename... qwq>
void debug(T x,qwq ...args)
{
	debug(x);
	debug(args...);
}
#define dflush fflush
#else
#define dflush(...) 0
template<typename T,typename... qwq>
void debug(T x,qwq ...args)
{
	
}
#endif

#define int long long
const int mod=998244353;
#ifdef int 
#define inf 0x3f3f3f3f3f3f3f3fll
#else 
#define inf 0x3f3f3f3f
#endif
inline int min(int a,int b){return a>b?b:a;}
inline int max(int a,int b){return a<b?b:a;}
#define cmlSEGMIN
#define cmlSEGMAX
#define cmlSEGSUM
class SegTreeAl{
#ifdef cmlSEGMIN
	int minn[1000005<<2];
#endif
#ifdef cmlSEGMAX
	int maxn[1000005<<2];
#endif
#ifdef cmlSEGSUM
	int sum[1000005<<2];
#endif
	int tag[1000005<<2];
#ifdef cmlSEGSUM
	void pushdown(int o,int l,int r)
#else 
	void pushdown(int o)
#endif
	{
		int&t=tag[o];
#ifdef cmlSEGMIN
		minn[o<<1]+=t;
		minn[o<<1|1]+=t;
#endif
#ifdef cmlSEGMAX
		maxn[o<<1]+=t;
		maxn[o<<1|1]+=t;
#endif
#ifdef cmlSEGSUM
		int m=l+r>>1;
		sum[o<<1]+=t*(m-l+1);
		sum[o<<1|1]+=t*(r-m);
#endif
		tag[o<<1]+=t;
		tag[o<<1|1]+=t;
		t=0;
	}
	void add(int o,int l,int r,int L,int R,int v)
	{
		if(L<=l&&r<=R)
		{
#ifdef cmlSEGMAX
			maxn[o]+=v;
#endif
#ifdef cmlSEGMIN
			minn[o]+=v;
#endif
#ifdef cmlSEGSUM
			sum[o]+=v*(r-l+1);
#endif
			tag[o]+=v;
			return;
		}
		int m=l+r>>1;
#ifdef cmlSEGSUM
		pushdown(o,l,r);
#else
		pushdown(o);
#endif
		if(L<=m)add(o<<1,l,m,L,R,v);
		if(m<R)add(o<<1|1,m+1,r,L,R,v);
#ifdef cmlSEGMAX
		maxn[o]=max(maxn[o<<1],maxn[o<<1|1]);
#endif
#ifdef cmlSEGMIN
		minn[o]=min(minn[o<<1],minn[o<<1|1]);
#endif
#ifdef cmlSEGSUM
		sum[o]=sum[o<<1]+sum[o<<1|1];
#endif
	}
#ifdef cmlSEGMIN
	int qmin(int o,int l,int r,int L,int R)
	{
		if(L<=l&&r<=R)
		{
			return minn[o];
		}
		int m=l+r>>1,res=inf;
#ifdef cmlSEGSUM
		pushdown(o,l,r);
#else
		pushdown(o);
#endif
		if(L<=m)res=min(res,qmin(o<<1,l,m,L,R));
		if(m<R)res=min(res,qmin(o<<1|1,m+1,r,L,R));
#ifdef cmlSEGMAX
		maxn[o]=max(maxn[o<<1],maxn[o<<1|1]);
#endif
#ifdef cmlSEGMIN
		minn[o]=min(minn[o<<1],minn[o<<1|1]);
#endif
#ifdef cmlSEGSUM
		sum[o]=sum[o<<1]+sum[o<<1|1];
#endif
		return res;
	}
#endif

#ifdef cmlSEGMAX
	int qmax(int o,int l,int r,int L,int R)
	{
		if(L<=l&&r<=R)
		{
			return maxn[o];
		}
		int m=l+r>>1,res=-inf;
#ifdef cmlSEGSUM
		pushdown(o,l,r);
#else
		pushdown(o);
#endif
		if(L<=m)res=max(res,qmax(o<<1,l,m,L,R));
		if(m<R)res=max(res,qmax(o<<1|1,m+1,r,L,R));
#ifdef cmlSEGMAX
		maxn[o]=max(maxn[o<<1],maxn[o<<1|1]);
#endif
#ifdef cmlSEGMIN
		minn[o]=min(minn[o<<1],minn[o<<1|1]);
#endif
#ifdef cmlSEGSUM
		sum[o]=sum[o<<1]+sum[o<<1|1];
#endif
		return res;
	}
#endif

#ifdef cmlSEGSUM
	int qsum(int o,int l,int r,int L,int R)
	{
		if(L<=l&&r<=R)
		{
			return sum[o];
		}
		int m=l+r>>1,res=0;
#ifdef cmlSEGSUM
		pushdown(o,l,r);
#else
		pushdown(o);
#endif
		if(L<=m)res+=qsum(o<<1,l,m,L,R);
		if(m<R)res+=qsum(o<<1|1,m+1,r,L,R);
#ifdef cmlSEGMAX
		maxn[o]=max(maxn[o<<1],maxn[o<<1|1]);
#endif
#ifdef cmlSEGMIN
		minn[o]=min(minn[o<<1],minn[o<<1|1]);
#endif
#ifdef cmlSEGSUM
		sum[o]=sum[o<<1]+sum[o<<1|1];
#endif
		return res;
	}
#endif
};
#define newe(n) struct Edge{int v,w,nxt;}e[2*n+5];\
typedef int arr[n+5];\
arr h;\
int cnt=1;\
inline void addedge(int u,int v,int w){e[cnt]=(Edge){v,w,h[u]};h[u]=cnt++;}\
struct node{\
	int u,d;\
	bool operator<(const node&b)const{return d>b.d;}\
};\
void dij(int s,int *d,int N)\
{\
	memset(d,0x3f,sizeof(int)*(N+3));\
	d[s]=0;std::priority_queue<node>q;q.push((node){s,0});\
	while(!q.empty())\
	{\
		int u=q.top().u,D=q.top().d;q.pop();if(D!=d[u])continue;\
		for(int i=h[u];i;i=e[i].nxt){int v=e[i].v,w=e[i].w;\
		if(d[u]+w<d[v])d[v]=d[u]+w,q.push((node){v,d[v]});\
		}\
	}\
}
#define mgs int fa[1<<22],sz[1<<22];\
inline int f(int x){return x==fa[x]?x:fa[x]=f(fa[x]);}\
inline int uf(int x,int y)\
{\
    int fx=f(x),fy=f(y);\
    if(fx==fy)return 0;\
    if(sz[fx]>sz[fy])fx^=fy^=fx^=fy;\
    fa[fx]=fy,sz[fy]+=sz[fx];\
    return 1;\
}
inline int read()
{
    int num=0,f=1;char c=getchar();
    while(c<48||c>57){if(c=='-')f=-1;c=getchar();}
    while(c>47&&c<58)num=num*10+(c^48),c=getchar();
    return num*f;
}
inline int re1d()
{
    char c=getchar();
    while(c<48||c>49)c=getchar();
    return c&1;
}
#ifdef cmlBIT
struct BIT{int a[1<<20|1],n;
void add(int x,int p){while(x<=n)a[x]+=p,x+=x&-x;}
int operator[](int x){int res=0;while(x)res+=a[x],x-=x&-x;return res;}
int operator()(int l,int r){return (*this)[r]-(*this)[l-1];}};
#endif
int rnv[1000005];
// #define COMB
#ifdef COMB
#ifndef int
#define int long long
#endif
int fac[1000005],inv[1000005];
#endif
void initprog()
{
#ifdef COMB
	fac[0]=inv[0]=inv[1]=1;
	rg(1000000)fac[i]=fac[i-1]*i%mod;gr
	rg(1000000)if(i>1)inv[i]=inv[mod%i]*(mod-mod/i)%mod;gr
	rg(1000000)rnv[i]=inv[i];gr
	rg(1000000)inv[i]=inv[i]*inv[i-1]%mod;gr
#endif
}
#ifdef COMB
int C(int n,int m)
{
	if(n==m||m==0)return 1;
	if(n<m)return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
#endif
inline int qp(int a,int b){int c=1;while(b){if(b&1)c=c*a%mod;a=a*a%mod;b>>=1;}return c;}
inline int mae(int &a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int mde(int &a,int b){a+=mod-b;if(a>=mod)a-=mod;return a;}
inline int mle(int &a,int b){a=a*b%mod;return a;}
inline int mve(int &a,int b){a=a*qp(b,mod-2)%mod;return a;}
inline int mxe(int &a,int b){return a=a>b?a:b;}
inline int mne(int &a,int b){return a=a<b?a:b;}
inline int ae(int a,int b){int c=a+b;return c>=mod?c-mod:c;}
inline int de(int a,int b){return ae(a,mod-b);}
inline int me(int a,int b){return a*b%mod;}
inline int mive(int &a,int b){a=a*rnv[b]%mod;return a;}
inline int ive(int a,int b){return a*rnv[b]%mod;}
inline int ve(int a,int b){return a*qp(b,mod-2)%mod;}
#ifdef cmlST
struct STmin{
	int a[21][1000005],n;
	void init(int N,int *b)
	{
		n=N;
		rg(n)a[0][i]=b[i];gr
		rg(20)rg_(j,n-(1<<i)+1)a[i][j]=min(a[i-1][j],a[i-1][j+(1<<i-1)]);gr gr
	}
	int q(int l,int r)
	{
		int d=std::__lg(r-l+1);
		return min(a[d][l],a[d][r-(1<<d)+1]);
	}
};
struct STmax{
	int a[21][1000005],n;
	void init(int N,int *b)
	{
		n=N;
		rg(n)a[0][i]=b[i];gr
		rg(20)rg_(j,n-(1<<i)+1)a[i][j]=max(a[i-1][j],a[i-1][j+(1<<i-1)]);gr gr
	}
	int q(int l,int r)
	{
		int d=std::__lg(r-l+1);
		return max(a[d][l],a[d][r-(1<<d)+1]);
	}
};
#endif
#ifdef cmlSAM
struct SAM{
	int ch[1000005][26],lnk[1000005],len[1000005],lst=1,cc=1;
	int sz[1000005];
	void insert(int c)
	{
		len[++cc]=len[lst]+1;sz[cc]=1;
		int p=lst;lst=cc;
		while(p&&ch[p][c]==0)ch[p][c]=cc,p=lnk[p];
		if(p==0)lnk[cc]=1;
		else
		{
			int x=ch[p][c];
			if(len[p]+1==len[x])lnk[cc]=x;
			else
			{
				int q=cc;++cc;
				lnk[cc]=lnk[x];
				lnk[x]=lnk[q]=cc;
				len[cc]=len[p]+1;
				memcpy(ch[cc],ch[x],sizeof(ch[cc]));
				while(p&&ch[p][c]==x)ch[p][c]=cc,p=lnk[p];
			}
		}
	}
	newe(1000005);
	long long ans;
	void build()
	{
		rg(cc)addedge(lnk[i],i,0);gr
	}
	void dfs(int u)
	{
		fe(u)dfs(v),sz[u]+=sz[v];gr
		if(sz[u]>1)ans=max(ans,1ll*sz[u]*len[u]);
	}
}t;
#endif

signed main()
{
	initprog();
	int T=read();rg(T)
	int x=read(),y=read(),k=read();
	int ns=0;
	int X=0;
	while((1ll<<X)<=k)X++;
	int Y=1ll<<X;
	// int hvd=0,dt=0;??
	do{
		// oldp(x,y);fflush(stdout);
		int flg=1;
		if(x>y)std::swap(x,y);
		if((x==y))oldl(ns);
		else if(x-y==1||y-x==1)oldl(ns+1);
		else if((x^y)<=k)oldl(ns+1);
		else if(k==0)oldl(y-x);
		else if((x^y)<Y)oldl(ns+2);
		else
		{
			flg=0;
			if((x&Y-1)==0)
			{
				int dt=Y;
				int oh=(y-x)/dt-3;
				if(oh>0)ns+=((k&(k+1))==0?2:3)*oh,x+=dt*oh;
				x^=k,ns++;
			}
			else
			{
				if((x&Y-1)==Y-1)x++,ns++;
				else
				{
					int t=0;
					for(int i=0;i<60;i++)
					{
						if((x>>i&1)==0&&(t|1ll<<i)<=k)
							x|=1ll<<i,t|=1ll<<i;
					}
						ns++;
				}
			}
		}
		if(flg)break;
	}while(1);
	gr
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 1752kb

input:

8
4 5 0
5 8 3
9 2 6
15 28 5
97 47 8
164 275 38
114514 1919 810
0 1152921504606846975 1

output:

1
2
3
5
11
6
331
1152921504606846975

result:

ok 8 numbers

Test #2:

score: 0
Accepted
time: 40ms
memory: 1752kb

input:

100000
84 318 6
54 226 7
92 33 0
39 54 5
76 79 7
247 110 0
211 90 0
4 430 3
230 17 1
491 93 5
196 117 7
137 29 2
76 490 6
422 43 7
277 26 4
159 43 1
67 37 5
17 2 5
113 176 7
85 473 0
68 217 7
275 8 7
124 34 1
30 66 0
80 149 3
103 149 6
84 354 1
27 342 7
94 114 1
69 125 1
72 48 7
361 8 7
285 82 1
74 ...

output:

87
45
59
6
1
137
121
213
213
150
21
81
156
95
95
116
12
6
16
388
39
67
90
36
35
17
270
79
20
56
6
89
203
108
26
15
157
98
111
389
174
123
59
289
78
17
21
36
275
191
17
102
60
93
100
11
6
79
44
63
91
60
22
109
11
3
10
67
11
85
207
47
39
83
156
189
107
27
81
247
81
335
33
144
11
50
54
347
233
175
30
7...

result:

ok 100000 numbers

Test #3:

score: 0
Accepted
time: 13ms
memory: 1512kb

input:

100000
322 25 2699
83 407 606
157 77 162
358 3 4064
407 35 1145
15 491 801
174 95 1886
67 93 2573
415 7 2014
16 203 2003
95 357 453
287 14 1247
63 108 3617
124 30 3806
116 425 830
483 63 2237
97 123 1194
124 460 2729
71 99 818
118 24 527
92 236 3298
446 55 413
0 122 3335
193 64 318
55 201 3120
475 8...

output:

1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
7
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
6
1
1
1
1
3
1
1
1
3
1
1
1
1
1
1
1
1
5
1
1
1
1
1
1
2
1
1
1
1
6
1
1
1
6
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
10
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
114
1
1
1
1
1
1
1
1...

result:

ok 100000 numbers

Test #4:

score: 0
Accepted
time: 21ms
memory: 1744kb

input:

100000
460 16 1999514420
38 120 459071025
36 5 435961014
415 44 1634888670
236 110 1172545331
116 449 1722938168
9 55 1093539809
98 9 2009254678
160 13 874849076
72 59 307472779
94 278 829310177
375 21 1588655085
85 272 1310414813
101 309 2072973009
96 370 510582365
55 6 285781515
45 99 743723479
43...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #5:

score: 0
Accepted
time: 14ms
memory: 1452kb

input:

100000
102 211 434535176914392191
113 382 10473939473902551
154 70 347749780432060530
307 4 770301859497555482
21 88 1148164284941713103
141 52 298799672146159282
86 67 592474494235856008
126 423 500925453682730053
72 23 751099353059890065
105 60 591595972426609814
1 312 322398882693527462
488 21 29...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #6:

score: 0
Accepted
time: 66ms
memory: 1460kb

input:

100000
900433230470865373 168 0
274936233345873548 263 0
107 912910047733415890 1
148108377912190269 159 1
637618261092082754 433 0
206160758979307706 117 5
374274670768546935 258 4
84 460392244654734212 6
568787141853147589 410 2
412 739540468281060656 2
420 372651009036366141 4
99 7542107804877648...

output:

900433230470865205
274936233345873285
912910047733415783
148108377912190110
637618261092082321
77310284617240347
140353001538205004
172647091745525298
426590356389860385
554655351210795183
139744128388637146
377105390243882372
137260618027802044
228162758321107513
238496406926521455
4701988644786694...

result:

ok 100000 numbers

Test #7:

score: 0
Accepted
time: 103ms
memory: 1696kb

input:

100000
188 488898411793715829 1662
510531470828119181 461 3880
438 860056315149583446 2443
42 812320392335060663 3402
217505267941559099 476 1869
733654172372163727 264 3646
489 830976331637915910 1805
320 291401742311195413 2413
727350143139117155 212 3564
741441713302666228 127 3543
235 6311872086...

output:

716159782900951
373924417110438
629924058947449
594961224854780
318611232336267
537344364530392
1217250485797728
213429010481833
532727155619470
543048129860350
924590637678442
364977615196297
623513894326819
700013580991870
919332840637041
328404862469641
208593246441270
504345408627412
79159378552...

result:

ok 100000 numbers

Test #8:

score: 0
Accepted
time: 119ms
memory: 1752kb

input:

100000
257065522585566918 30 1812115310
83844174930688960 422 1624142137
375 469381000404632137 2011601386
3 867947326951574129 565346038
492077250720556083 481 302247286
12568100705985631 46 1125722166
920283886245013913 437 1819207161
447 543496034445506022 1182065585
303 120270820941724589 262528...

output:

359116387
117128959
655717681
2425016818
2749695913
17557433
1285621738
759255190
1344131167
6268476244
3054607769
1236129328
238549747
166968007
1286435771
6436773067
125390267
2868985966
1322338912
945384623
1498197809
539118172
640614664
1478520541
626183317
9372581165
1142622586
1236092431
13418...

result:

ok 100000 numbers

Test #9:

score: 0
Accepted
time: 42ms
memory: 1744kb

input:

100000
428068929935037839 388 630663327499068933
262 958123279540916859 771299383434598713
428 822514876586340933 987799047076516848
237287479925224365 312 424435087833422191
701225953118656766 161 833708981315149466
394956250518140170 204 217521001178891893
257 1053780657770182567 11160907334756932...

output:

1
2
1
1
1
4
1
1
1
1
1
4
5
34
2
16
4
1
10
1
2
1
2
2
2
2
1
2
1
1
1
5
2
1
1
13
1
1
2
2
11
7
64
13
1
1
1
1
1
2
487
1
5
8
5
1
1
1
1
4
4
1
4
2
1
4
10
1
1
2
4
1
2
10
4
5
1
2
2
2
2
5
2
4
4
1
25
1
2
10
2
4
1
1
13
13
1
1
1
16
1
1
1
2
2
47
7
1
7
1
2
1
1
4
2
2
4
11
2
11
1
1
4
2
2
7
2
2
4
2
2
2
1
1
1
1
1
1
1
2
8...

result:

ok 100000 numbers

Test #10:

score: 0
Accepted
time: 55ms
memory: 1456kb

input:

100000
85 421507 4
496297 10 7
356332 44 3
76 577303 5
351031 94 7
58 140834 6
29 933102 3
38 216181 3
546264 89 7
31 422649 5
109311 68 5
120 513750 4
497068 79 4
65 86390 2
283497 42 7
75 649345 0
71 38397 6
613856 39 7
594802 87 3
1032126 38 7
529937 74 6
90 63617 3
199780 82 0
19 286420 2
792882...

output:

158034
124073
178144
216460
87735
52791
466537
108073
136544
158483
40966
192611
186371
64743
70865
649270
14372
153455
297358
258023
198699
31765
199698
214801
594589
203256
187717
156414
193355
248657
12460
160862
788822
482410
333798
343807
106109
410238
173416
893773
143015
115984
252105
134100
...

result:

ok 100000 numbers

Test #11:

score: 0
Accepted
time: 85ms
memory: 1604kb

input:

100000
392435 60 3657
48 379529 2580
460273 13 529
178138 58 1250
65 172539 1647
383884 81 1122
60 818634 2731
811128 118 2044
28 58969 589
514487 106 2905
874719 68 1312
46 578211 1635
84 856790 3883
876243 3 3395
46 631287 185
106 240163 97
114 1012795 3666
35 34985 3175
1 419802 191
49 657088 262...

output:

286
278
1348
260
253
562
599
1188
173
376
1282
847
628
641
7397
5628
742
25
4919
481
1378
286
755
602
5
712
514
265
2509
517
358
298
151
958
148
843
19
1456
466
775
136
145
406
385
691
22651
749
88
148
629
1620
322
739
643
983
547
85
616
3038
490
514
346
2350
238
703
424
242
5332
389
112
313
334
461...

result:

ok 100000 numbers

Test #12:

score: 0
Accepted
time: 12ms
memory: 1692kb

input:

100000
185932 2 938020241
122 450092 247160688
421772 121 1933778669
191969 15 1053606012
830655 15 1697646325
16 741472 1012788245
114212 108 1939020027
1023243 68 875622059
157245 122 1686052494
53 525698 181916400
97 330187 1577084801
44 26023 632336853
442318 10 747297252
480154 50 721797770
811...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #13:

score: 0
Accepted
time: 17ms
memory: 1484kb

input:

100000
121 831582 1132382698460100719
854677 9 791000264142579750
114 594892 718123681588947593
81 198907 307112382652039393
647901 37 783561625628024954
83 232049 374223523517787944
597370 34 559296931095396836
503871 20 818832724331892685
802313 21 911117211700034289
17 922367 1114109760856744511
...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 59ms
memory: 1492kb

input:

100000
1117862588729209192 762936 3
51787830086551971 1002999 0
196674022833618532 538452 2
1082937251836821513 10186 7
416454037132497157 220619 3
140455106307683420 325948 4
407028 147347965053157557 7
2070 331803764565270332 5
1085729941037194683 197609 0
480451279180004754 947702 7
1806930993983...

output:

558931294364223128
51787830085548972
147505517124810060
270734312959202833
208227018566138270
52670664865259052
36836991263187633
124426411711975599
1085729941036997074
120112819794764265
67759912274129249
21308561722547452
102925549516609787
272930161441196065
141673678896096145
1055958431742256509...

result:

ok 100000 numbers

Test #15:

score: 0
Accepted
time: 113ms
memory: 1748kb

input:

100000
985847471568982965 676880 2029
371404268141610691 941633 1066
755437147530254580 711705 2945
774090 722706686208136825 3723
54520 896774967379280920 2713
219965 686986400756587945 3117
102640172347630747 635043 380
56365 653855598747418224 3315
477262 448502573787259708 1967
146799 7252580754...

output:

1444112507180136
544049220909184
553298692038240
529326186187035
656817603060958
503163867741481
601407259845678
478898143613791
656986192070482
1062389758934749
52064696158245
941685793855428
559425073200021
805652028169206
664596806558066
4202331239419321
1262247837130710
687903680710997
130880521...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 133ms
memory: 1496kb

input:

100000
329358874618991013 193926 1861315148
199319758836385240 654883 882120846
314346 262913994609852844 1053497487
1017229 665510310561347538 619188376
436544 445409479104980301 1117236068
593128 437153441727580149 2076848805
129816233779422452 1024161 1243937151
924004001869553483 721209 13132490...

output:

460109032
556892972
734573215
1859414327
622229854
610696303
181351183
1290818678
1299852079
762058444
1309785401
4019433799
5920828865
6134797009
236480954
1311986099
594877967
2810221058
694363724
1368260812
2244349727
2480789429
124270837
678726092
1610423407
559609507
3050154839
1527667756
13884...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 38ms
memory: 1520kb

input:

100000
211791903010682984 1038358 535289827231177928
639594184787170459 469458 328856594957100884
587279 450401032845407848 730831795215014583
900020916033422919 865031 1100282449791494376
593820172742961795 204920 984080826401173681
853023782666264310 689931 784150389810194141
73535045456261069 477...

output:

1
4
1
1
1
2
1
4
13
1
5
1
10
1
1
1
4
1
8
5
5
1
4
22
5
1
5
1
2
1
1
2
68
22
1
1
2
31
1
1
1
2
1
1
1
1
1
634
17
1
1
1
1
1
1
4
2
11
4
4
2
2
2
1
2
1
1
4
1
19
1
7
2
1
2
1
1
4
1
2
1
4
1
1
2
16
1
4
1
1
1
1
1
1
2
1
11
16
4
2
10
1
2
1
37
1
1
5
5
5
2
1
1
7
1
1
1
23
4
1
11
1
1
4
1
2
2
7
1
1
2
1
2
5
4
19
31
1
2
4
...

result:

ok 100000 numbers

Test #18:

score: 0
Accepted
time: 42ms
memory: 1460kb

input:

100000
1437942565 43 5
233522811 73 2
685503186 5 6
1200375515 41 3
112 697453465 5
12 1053068003 0
166843878 33 0
794516384 72 0
13 1726680934 4
1331715935 114 6
106 1290615558 4
855468459 94 0
1981952243 44 7
34 140266324 3
1329475226 7 1
1486922341 19 4
115 266577576 0
989178412 70 7
34 193954228...

output:

539228445
175142053
257063694
600187737
261545008
1053067991
166843845
794516312
647505346
499393432
483980795
855468365
495488051
70133146
1329475219
557595871
266577461
247294587
1939542249
324535700
606307860
683791781
32417176
445452003
1333791761
232423116
252561332
384160543
1386260830
3895105...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 89ms
memory: 1500kb

input:

100000
750914597 40 1901
534716046 109 2559
1582066673 61 1769
113 1909787022 964
86 1449875704 957
43 1537130136 1559
832677927 38 1191
112 1167713080 598
36 238371756 2467
1320983099 84 2846
4 606010098 3054
45 1689211823 1100
2022593191 60 3590
16 1442487521 765
973165753 127 2983
81 189329502 34...

output:

1099972
391637
2317480
5595078
4247682
2251655
1219744
3421034
174589
967516
443854
2474431
1481392
4226038
712768
138670
220435
1041241
2975038
2957677
1119485
2715832
572593
1493527
519721
66056
181288
1526644
411406
12335828
544250
871849
7233058
1708618
1556176
1215887
4064140
7114532
2914075
30...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 40ms
memory: 1756kb

input:

100000
7 212840355 1351365326
325418128 123 2107758625
1110761471 46 920576804
132180347 13 612895632
27 1760170375 542674255
313451543 109 1743977216
44 1091009299 480895092
23 484821208 1439315252
126 1103409846 1171365624
72 1190132595 1446675505
15662534 110 684191360
125 781989597 544947517
24 ...

output:

1
1
4
1
5
1
7
1
1
1
1
2
1
1
7
1
5
1
14
1
1
2
1
1
4
2
1
1
1
1
1
1
5
1
1
5
1
2
1
1
2
1
1
1
22
1
1
4
1
1
2
22
4
2
4
1
2
5
2
7
1
4
1
1
1
4
10
1
1
1
8
1
127
5
4
1
1
2
1
1
7
5
1
2
1
2
172
1
1
2
7
1
4
2
1
1
1
1
1
1
1
2
1
7
11
2
1
4
4
1
2
4
1
5
1
76
1
1
1
4
1
1
2
1
4
1
235
2
1
2
2
1
2
14
1
1
2
2
1
1
2
1
1
1...

result:

ok 100000 numbers

Test #21:

score: 0
Accepted
time: 20ms
memory: 1744kb

input:

100000
738645303 44 516300324926153733
6 2817393 921008837249510931
735824990 25 924626853631078712
75 1887692236 132671755297217183
123 436370401 47934974366463749
120 1875330451 701688582743216444
1208403246 7 471267810286592170
97 700505811 990921976869001194
34 2093211186 463456366822251
2094508...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 87ms
memory: 1460kb

input:

100000
482660647546476097 1185031966 7
164808124 740618915243965567 6
1801791413 793117080257705718 0
1395821708 1048793452358556891 1
1932981956 31899692695022089 1
1318914151 656924813513699198 1
620404249181623260 1589178242 1
1589928614 827930147024380905 5
174947014777385743 1332587881 3
327929...

output:

120665161590361035
277732093154684041
793117078455914305
1048793450962735183
31899690762040133
656924812194785047
620404247592445018
310473804537919611
87473506722398931
59759728989590520
438337529107067266
208326416947422147
5209863496365379
257164449140175276
156827145366961996
382455907069504124
...

result:

ok 100000 numbers

Test #23:

score: 0
Accepted
time: 107ms
memory: 1744kb

input:

100000
365437149714877541 1780464145 3269
637665292855593723 585150453 779
1325634327 725054698761495561 2255
1102361302 722006281113885907 64
910600682584658691 1184235350 1173
933289468 466162208405300515 1671
1220414966 230250531813092131 2258
600153265 857658903444502658 2657
319928929258538259 ...

output:

267654161084775
1868160035948565
531045920973532
16922022187770109
1333887716895153
682854796101579
168640525336435
628168141731702
234322945584345
364554617624560
10083313349337318
559135113254025
705964639257085
508007409691767
1047453526675991
9312448475486
870042621223819
638146394969433
1224754...

result:

ok 100000 numbers

Test #24:

score: 0
Accepted
time: 137ms
memory: 1460kb

input:

100000
854675358444377326 2119263737 149247452
1727006082 336779754515641632 602149100
700882962 356680850180255478 1381730310
1502599769 609802764365901802 586385085
224585295343627463 2113467115 750638527
564763801193041533 1312647739 745638395
156356867706250590 365191461 1335875908
1085894972074...

output:

9551741442
940951761
498277391
1703769238
627484062
1577931829
218428021
1516977750
1078474986
1451101464
697835241
3982860671
289577792
4940114727
2648274483
601936878
1529461266
213771006
1245581185
838226301
3219713566
340915506
1382000421
1152660972
2032713934
304324927
3146727525
974763210
9914...

result:

ok 100000 numbers

Test #25:

score: 0
Accepted
time: 41ms
memory: 1496kb

input:

100000
1434620072 868292152925984526 969590329142935034
758406947148898454 950016661 899090649112510540
867695890485660915 870003428 275252443500128738
234426442167893487 1546397228 409848412401881244
17485296530777613 1457516901 434590951680082740
541374948 332496545751374519 796002481753142832
338...

output:

1
1
10
1
1
1
1
1
1
1
1
5
2
1
1
1
2
1
1
1
1
13
1
1
1
1
1
5
4
1
4
4
1
4
1
4
1
1
1
7
13
1
7
1
4
2
1
1
2
4
1
1
2
2
4
1
1
41
23
22
4
1
1
1
17
1
4
2
1
1
1
116
1
1
10
1
1
1
4
1
1
1
4
1
10
10
4
5
2
4
10
1
1
4
2
4
1
1
4
22
2
1
1
2
4
10
52
1
4
7
4
11
1
4
1
4
1
4
5
1
1
1
2
1
1
2
7
1
1
1
1
22
2
1
1
155
2
46
1
5...

result:

ok 100000 numbers

Test #26:

score: 0
Accepted
time: 51ms
memory: 1696kb

input:

100000
39 346489936481992578 2
19 938605854271045828 2
533972989469209375 30 2
92 664357542641453386 1
61 24997380520790761 2
100 899955567648592547 2
72 102663594750289139 5
557235412803812906 79 6
67 483964315599574872 3
108 816568261692802994 7
111 1066384252622684834 0
71 93681462634521057 6
102...

output:

259867452361494404
703954390703284357
400479742101907009
664357542641453294
18748035390593025
674966675736444335
38498848031358400
208963279801429811
241982157799787403
204142065423200723
1066384252622684723
35130548487945371
512352167152943310
156258961358861999
1002098132581363271
1534765011739728...

result:

ok 100000 numbers

Test #27:

score: 0
Accepted
time: 89ms
memory: 1760kb

input:

100000
67 452739344572491893 2747
119 971079485269879233 3193
32 344467895301239544 3433
183301704200822394 62 2903
33 763471348854530836 304
48 673975553329542227 3047
12 425863113085566329 690
451368902032819204 70 2817
581844031383386694 78 3753
495222713547669423 114 832
332967009692678301 19 37...

output:

331596199638055
711239857375399
252295821753838
134254177881461
4473464934694516
493634438473786
1247645839117870
330592457543569
426155296423378
1450847793596687
243872321552254
41081364198478
8361647497761787
739458400291859
5636774061988582
615460750049881
325709562764707
3004000133377
1062263140...

result:

ok 100000 numbers

Test #28:

score: 0
Accepted
time: 126ms
memory: 1444kb

input:

100000
58 37300143208110277 1617222872
860745148898492456 1 1371084676
367389542906006331 99 1888733613
1130661363847188255 23 703420111
74 1048463439723743560 981941239
488415894311982589 30 760622661
608233717117417177 39 2023852401
108 791366799669143885 1026690628
1018098089268157420 26 97664934...

output:

52107697
1202447083
513237262
3159031357
2929373011
1364618245
849692686
2211053296
2844533200
4375860793
1394512055
251072341
1780476817
925441331
649437424
1248681016
109090708
2936523934
1290417148
883098115
207989293
1348195003
959221424
169218335
370268471
2477465782
1214792168
1546732468
46533...

result:

ok 100000 numbers

Test #29:

score: 0
Accepted
time: 36ms
memory: 1488kb

input:

100000
342471042011595857 32 87226565166468789
40 819401467523789587 694266742627594346
48 1069630456235229270 1119026694174612869
111 658375227778071907 1075990422795071768
114 1045029262577394099 242040158122154919
163896217459514741 23 556399655940251050
251258157228644499 16 336100450849996694
4...

output:

7
2
1
1
10
1
1
2
1
13
1
22
4
1
1
1
4
2
7
16
1
304
1
5
1
5
2
4
1
7
7
1
1
1
1
1
1
10
1
2
2
1
1
1
5
1
4
1
11
1
4
4
1
1
4
7
4
10
1
1
2
4
1
2
1
10
2
1
2
1
4
1
1
1
10
8
1
2
4
1
2
19
1
2
4
2
1
4
4
1
1
7
41
4
1
1
1
1
1
2
1
2
1
1
4
1
1
55
10
1
10
2
1
1
1
10
1
4
5
2
1
1
10
5
10
1
1
1
5
2
1
1
4
4
10
1
1
4
1
10...

result:

ok 100000 numbers

Test #30:

score: 0
Accepted
time: 63ms
memory: 1760kb

input:

100000
152598024252556634 681654813376472939 3
681938946300942863 628897116094378528 5
811684279997734855 270403556967279343 3
672017587820376686 897601668331566194 6
912345664171921371 568781582077049448 1
374814196103956320 211610288105962177 4
347285812072843961 586812129155809702 1
1066037307509...

output:

264528394561958153
19890686327461625
270640361515227756
84594030191696067
343564082094871923
61201465499247804
239526317082965741
788467533416657595
219925561594958321
117205748047025513
100717880539089330
737554201043623548
133231266027956184
49724331158429930
365606842775771163
151239744525625879
...

result:

ok 100000 numbers

Test #31:

score: 0
Accepted
time: 117ms
memory: 1744kb

input:

100000
592726515487329224 429035372458611525 3557
901106767948864261 503456228772786564 1751
96314421358194503 913574556376953011 1141
390352892147563481 620635509950221179 2166
739846426899529064 371334464192841288 1690
1021557121699862580 614090573068717599 288
966158256440584566 70981740347419960...

output:

119890973897985
582495906996207
1197158400906387
168664026710932
539812445371125
2387499308385616
375499296337479
217202675308020
1019407257080643
676939477460419
504438557238913
1608057103560525
213583066896348
1835261361867519
35943234730259
328403961154489
410097847827405
280036780713565
23410269...

result:

ok 100000 numbers

Test #32:

score: 0
Accepted
time: 136ms
memory: 1744kb

input:

100000
567213331731061155 847461263624081717 1117404261
693118528681237547 385911455040269094 2110725569
160842822646904494 216660015199408165 1331217885
530693905413793180 140069811669875203 378880871
738103499814402870 419383843958127482 933994897
727669139897338527 158507491000465434 76432787
425...

output:

391501838
429163326
77975718
2182782220
890492430
12721754215
1635618013
365334591
1116886032
130852706
4643892717
1363541163
752816520
877244164
285316143
4019423907
168262805
251343106
23772743
1138735545
1251824790
2750255892
1796647639
937542135
597988647
5291409339
748772740
929519049
24533883
...

result:

ok 100000 numbers

Test #33:

score: 0
Accepted
time: 64ms
memory: 1744kb

input:

100000
1045557359662210853 853864343798662305 936192839816843204
528273158249108026 1052645593213902395 548804101449971471
711026077457415003 804057235279512905 1061801069946384788
797778816121912908 133233860528402977 1082197052750853322
530764695067707856 136729970998134649 897028734433829579
5395...

output:

1
3
1
1
1
2
1
1
1
1
1
1
7
2
6
1
1
2
1
3
1
1
1
1
1
6
4
4
1
2
1
3
1
2
1
1
1
12
16
3
2
2
1
1
6
3
6
1
2
1
4
1
1
3
1
2
1
15
3
2
15
2
1
9
18
1
1
1
3
1
12
4
1
2
3
1
6
2
3
2
33
1
2
3
2
1
2
2
9
2
27
6
1
19
2
1
1
1
1
3
4
3
1
2
1
3
1
1
1
2
4
1
5
2
1
1
1
4
1
3
8
1
1
7
2
9
1
1
1
3
1
1
2
1
1
1
1
2
1
1
1
24
1
3
18...

result:

ok 100000 numbers