QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#554690#9254. Random VariablesN_z_AC ✓575ms15492kbC++145.3kb2024-09-09 14:35:512024-09-09 14:35:52

Judging History

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

  • [2024-09-09 14:35:52]
  • 评测
  • 测评结果:AC
  • 用时:575ms
  • 内存:15492kb
  • [2024-09-09 14:35:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct time_helper
{
#ifdef LOCAL
	clock_t time_last;
#endif
	time_helper()
	{
#ifdef LOCAL
		time_last=clock();
#endif
	}
	void test()
	{
#ifdef LOCAL
		auto time_now=clock();
		std::cerr<<"time:"<<1.*(time_now-time_last)/CLOCKS_PER_SEC<<";all_time:"<<1.*time_now/CLOCKS_PER_SEC<<std::endl;
		time_last=time_now;
#endif
	}
	~time_helper()
	{
		test();
	}
}time_helper;
#ifdef LOCAL
#include"dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
namespace Fread{const int SIZE=1<<16;char buf[SIZE],*S,*T;inline char getchar(){if(S==T){T=(S=buf)+fread(buf,1,SIZE,stdin);if(S==T)return'\n';}return *S++;}}namespace Fwrite{const int SIZE=1<<16;char buf[SIZE],*S=buf,*T=buf+SIZE;inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}inline void putchar(char c){*S++=c;if(S==T)flush();}struct NTR{~NTR(){flush();}}ztr;}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
#define Setprecision 10
#define between '\n'
#define __int128 long long
template<typename T>struct is_char{static constexpr bool value=(std::is_same<T,char>::value||std::is_same<T,signed char>::value||std::is_same<T,unsigned char>::value);};template<typename T>struct is_integral_ex{static constexpr bool value=(std::is_integral<T>::value||std::is_same<T,__int128>::value)&&!is_char<T>::value;};template<typename T>struct is_floating_point_ex{static constexpr bool value=std::is_floating_point<T>::value||std::is_same<T,__float128>::value;};namespace Fastio{struct Reader{template<typename T>typename std::enable_if_t<std::is_class<T>::value,Reader&>operator>>(T&x){for(auto &y:x)*this>>y;return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1;while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}x=0;while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;return *this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1,s=0;x=0;T t=0;while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else return x*=f,*this;while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Reader&>operator>>(T&c){c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();return *this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}Reader&operator>>(std::string&str){str.clear();char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';struct Writer{typedef __int128 mxdouble;template<typename T>typename std::enable_if_t<std::is_class<T>::value,Writer&>operator<<(T x){for(auto &y:x)*this<<y<<between;*this<<'\n';return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Writer&>operator<<(T x){if(x==0)return putchar('0'),*this;if(x<0)putchar('-'),x=-x;static int sta[45];int top=0;while(x)sta[++top]=x%10,x/=10;while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Writer&>operator<<(T x){if(x<0)putchar('-'),x=-x;x+=pow(10,-Setprecision)/2;mxdouble _=x;x-=(T)_;static int sta[45];int top=0;while(_)sta[++top]=_%10,_/=10;if(!top)putchar('0');while(top)putchar(sta[top]+'0'),--top;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Writer&>operator<<(T c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return *this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(std::string str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
template<class Fun>class y_combinator_result{Fun fun_;public:template<class T>explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}template<class ...Args>decltype(auto) operator()(Args &&...args){return fun_(std::ref(*this), std::forward<Args>(args)...);}};template<class Fun>decltype(auto) y_combinator(Fun &&fun){return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));}

void solve();
int p;
int C[1001][1001],col[1001][1001],dp[1001][1001];
main()
{
	int t=1;
	cin>>t>>p;
	C[0][0]=1;
	for(int x=1;x<=1000;x++)
	{
		C[x][0]=1;
		for(int y=1;y<=1000;y++)
		C[x][y]=(C[x-1][y]+C[x-1][y-1])%p;
	}
	while(t--)solve();
}
int n,m,k;
int calc(int n,int m)
{
	if(n<0||m<0)return 0;
	if(n==0)return 1;
	if(m==0)return 0;
	if(col[n][::m-m]==k)return dp[n][::m-m];
	col[n][::m-m]=k;
	return dp[n][::m-m]=(1ll*calc(n-1,m)*m-1ll*calc(n-k-1,m-1)*m%p*C[n-1][k])%p;
}
void solve()
{
	cin>>n>>m;
	for(int x=0;x<=n;x++)
	for(int y=0;y<=n;y++)
	col[x][y]=0;
	k=n;
	int res=1ll*n*calc(n,m)%p;
	for(k=1;k<n;k++)
	res=(res-calc(n,m))%p;
	cout<<(res+p)%p<<endl;
}

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

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 11584kb

input:

3 123456789
3 2
5 5
7 7

output:

18
7145
2066323

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 3ms
memory: 9756kb

input:

100 2
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
8 1
8 2...

output:

1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 11592kb

input:

100 3
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
8 1
8 2...

output:

1
2
0
1
2
0
1
2
0
1
2
0
0
2
0
0
2
0
0
2
0
0
0
0
0
0
0
0
0
0
1
2
0
1
2
0
1
2
0
1
2
2
0
2
2
0
2
2
0
2
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
0
1
2
2
0
2
2
0
2
2
0
2
0
0
0
0
0
0
0
0
0
0
1
2
0
1
2
0
1
2
0
1

result:

ok 100 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 11184kb

input:

100 4
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
8 1
8 2...

output:

1
2
3
0
1
2
3
0
1
2
2
2
0
0
2
2
0
0
2
2
3
2
3
0
3
2
3
0
3
2
0
0
0
0
0
0
0
0
0
0
1
2
3
0
1
2
3
0
1
2
2
0
2
0
2
0
2
0
2
0
3
0
3
0
3
0
3
0
3
0
0
0
0
0
0
0
0
0
0
0
1
2
3
0
1
2
3
0
1
2
2
0
2
0
2
0
2
0
2
0

result:

ok 100 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 9872kb

input:

100 5
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
8 1
8 2...

output:

1
2
3
4
0
1
2
3
4
0
2
1
2
0
0
2
1
2
0
0
3
3
1
3
0
3
3
1
3
0
4
4
2
4
0
4
4
2
4
0
0
0
0
0
0
0
0
0
0
0
1
2
3
4
0
1
2
3
4
0
2
3
3
2
0
2
3
3
2
0
3
4
1
2
0
3
4
1
2
0
4
4
4
4
0
4
4
4
4
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 lines

Test #6:

score: 0
Accepted
time: 3ms
memory: 9704kb

input:

100 6
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
8 1
8 2...

output:

1
2
3
4
5
0
1
2
3
4
2
0
0
2
0
0
2
0
0
2
3
0
3
0
3
0
3
0
3
0
4
2
0
4
2
0
4
2
0
4
5
2
3
2
5
0
5
2
3
2
0
0
0
0
0
0
0
0
0
0
1
0
3
4
3
0
1
0
3
4
2
2
0
2
2
0
2
2
0
2
3
0
3
0
3
0
3
0
3
0
4
2
0
4
2
0
4
2
0
4

result:

ok 100 lines

Test #7:

score: 0
Accepted
time: 0ms
memory: 10844kb

input:

100 7
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
8 1
8 2...

output:

1
2
3
4
5
6
0
1
2
3
2
6
5
6
2
0
0
2
6
5
3
4
2
3
6
3
0
3
4
2
4
2
3
5
2
5
0
4
2
3
5
5
3
6
5
4
0
5
5
3
6
0
6
1
1
6
0
6
0
6
0
0
0
0
0
0
0
0
0
0
1
2
3
4
5
6
0
1
2
3
2
1
4
4
1
2
0
2
1
4
3
3
4
3
4
4
0
3
3
4

result:

ok 100 lines

Test #8:

score: 0
Accepted
time: 3ms
memory: 10900kb

input:

100 8
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
8 1
8 2...

output:

1
2
3
4
5
6
7
0
1
2
2
6
4
4
6
2
0
0
2
6
3
2
3
4
3
6
3
0
3
2
4
4
0
0
4
4
0
0
4
4
5
6
3
4
1
2
7
0
5
6
6
4
6
0
6
4
6
0
6
4
7
4
3
0
7
4
3
0
7
4
0
0
0
0
0
0
0
0
0
0
1
6
3
4
5
2
7
0
1
6
2
4
6
0
2
4
6
0
2
4

result:

ok 100 lines

Test #9:

score: 0
Accepted
time: 3ms
memory: 9880kb

input:

100 9
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
8 1
8 2...

output:

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

result:

ok 100 lines

Test #10:

score: 0
Accepted
time: 3ms
memory: 10196kb

input:

100 10
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
8 1
8 ...

output:

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

result:

ok 100 lines

Test #11:

score: 0
Accepted
time: 3ms
memory: 9996kb

input:

100 11
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
8 1
8 ...

output:

1
2
3
4
5
6
7
8
9
10
2
6
1
9
8
9
1
6
2
0
3
7
7
9
8
10
10
3
6
3
4
0
5
5
10
10
8
9
9
6
5
0
4
10
6
7
10
4
2
7
6
10
4
5
3
2
0
7
2
5
7
5
2
8
6
1
6
0
3
6
8
6
6
3
2
4
8
3
6
9
9
8
10
2
8
6
10
9
3
1
10
0
4
3
0
6
0
7
4
9

result:

ok 100 lines

Test #12:

score: 0
Accepted
time: 218ms
memory: 15404kb

input:

10 972033073
576 523187654
758 588616188
30 532959085
476 481773028
573 76725430
520 142462406
865 820120297
687 526533288
913 38106557
67 924529654

output:

259748390
909910217
708973357
300073565
463921261
889897372
587262932
255642402
868975954
14589849

result:

ok 10 lines

Test #13:

score: 0
Accepted
time: 278ms
memory: 15492kb

input:

10 922366485
846 278501607
683 609355362
44 978777279
545 730718412
926 323835432
883 761846029
623 408215612
989 588832935
449 743830620
259 183431187

output:

461786112
672633342
164805246
547995105
9661617
154501063
370848893
402005970
886523490
435107511

result:

ok 10 lines

Test #14:

score: 0
Accepted
time: 265ms
memory: 15396kb

input:

10 13890975
949 837425969
667 981449995
991 564074312
501 604745038
593 640307170
128 408163542
80 976891742
930 710947599
852 333118419
250 333252788

output:

3898759
9290500
7087084
4913904
196250
1746549
9627740
8673120
10274253
10549775

result:

ok 10 lines

Test #15:

score: 0
Accepted
time: 144ms
memory: 15396kb

input:

10 105576445
649 937885257
141 713063090
253 716966251
845 330657011
347 664392407
810 50478969
389 530582574
228 199722046
85 256258366
605 3721959

output:

22721419
27962190
85541228
53950260
35288938
100176945
86409840
102331663
55591445
14790745

result:

ok 10 lines

Test #16:

score: 0
Accepted
time: 186ms
memory: 15340kb

input:

10 445185474
268 687201814
929 296077349
690 202741564
372 661889855
442 989604795
367 456833096
702 862601129
795 37538865
556 131444040
108 645857776

output:

39577672
390323147
423333756
49417686
12978114
278291170
60346062
410583855
68429394
296833176

result:

ok 10 lines

Test #17:

score: 0
Accepted
time: 265ms
memory: 15472kb

input:

10 265384486
870 503808438
959 733458117
126 226376632
979 205878607
747 270352323
339 384431347
373 659485098
597 832514575
832 906898547
12 869891031

output:

54820154
83262107
48675762
32938269
169458409
153632065
105152812
48645927
29870948
83831862

result:

ok 10 lines

Test #18:

score: 0
Accepted
time: 182ms
memory: 15420kb

input:

10 869896294
256 326197921
496 115501273
861 238744067
581 600444623
619 536213251
89 898877607
136 353575223
860 349472278
491 770026371
668 622723560

output:

678111040
344947200
90686837
157367547
295943299
25262829
81930384
532341712
23048077
475131428

result:

ok 10 lines

Test #19:

score: 0
Accepted
time: 326ms
memory: 15412kb

input:

10 692092859
831 647975618
792 737778459
392 768554014
854 612888229
31 148093584
793 559010229
970 237393805
339 914914862
831 979073722
988 738224088

output:

324659472
16793498
421391172
416475848
59704753
347151224
415078841
680610884
397373492
296521551

result:

ok 10 lines

Test #20:

score: 0
Accepted
time: 145ms
memory: 15408kb

input:

10 827165684
577 720722656
383 778750361
951 59165685
502 993162103
589 166261195
500 816688874
40 625075150
331 160531509
394 578798823
181 710984062

output:

736529364
199088527
528654835
586634074
442300715
383600380
707706396
763397655
534310310
338272096

result:

ok 10 lines

Test #21:

score: 0
Accepted
time: 139ms
memory: 15400kb

input:

10 691312083
185 445519030
93 44970277
951 662144708
252 766000017
83 911805458
424 816227326
770 136026896
354 763387805
247 458147285
747 14566368

output:

411209183
132362175
110569626
664410537
241484162
480388660
264805387
294178848
147876955
371900799

result:

ok 10 lines

Test #22:

score: 0
Accepted
time: 575ms
memory: 15408kb

input:

10 691312083
1000 445519030
1000 44970277
1000 662144708
1000 766000017
1000 911805458
1000 816227326
1000 136026896
1000 763387805
1000 458147285
747 14566368

output:

365043118
14826361
571573673
63977538
484010015
499398766
433242788
43269113
412491407
371900799

result:

ok 10 lines

Extra Test:

score: 0
Extra Test Passed