QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#669090 | #8726. Magic Show | pyiming | 0 | 0ms | 1868kb | C++14 | 1.3kb | 2024-10-23 17:14:37 | 2024-10-23 17:14:45 |
Alice
#include"Alice.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e3;
// int exgcd(int a,int b,int &x0,int &y0){
// if(b==0){
// x0=1;
// y0=0;
// return a;
// }
// int g=exgcd(b,a%b,y0,x0);
// y0-=a/b*x0;
// return g;
// }
ll setN(int n);
vector<pair<int,int>> Alice(){
ll x=setN(N);
vector<pair<int,int>> edges;
for(int i=2;i<=N;i++){
edges.push_back({x%(i-1)+1,i});
}
return edges;
}
Bob
#include"Bob.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int V=1e18;
int exgcd(int a,int b,int &x0,int &y0){
if(b==0){
x0=1;
y0=0;
return a;
}
int g=exgcd(b,a%b,y0,x0);
y0-=a/b*x0;
return g;
}
ll Bob(vector<pair<int,int>> edges){
vector<pair<int,int>> t;
__int128 n=1;
for(auto i:edges){
int x=i.first,y=i.second;
if(x>y){
swap(x,y);
}
y--;
x--;
n*=y;
t.push_back({x,y});
if(n>V){
break;
}
}
__int128 X=0;
for(auto i:t){
int a=i.first,b=i.second;
__int128 m=n/b;
int x,y;
exgcd(m%b,b,x,y);
x=(x%b+b)%b;
X=(X+a*m*x)%n;
}
return X;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms = 0ms + 0ms
memory: 1864kb,1812kb
input:
1 4005
output:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 2 3 1 4 2 5 1 6 4 7 2 8 6 9 1 10 6 11 2 12 10 13 2 14 2 15 1 16 6 17 11 18 10 19 16 20 6 21 16 22 2 23 4 24 22 25 6 26 2 27 10 28 2 29 4 30 16 31 7 32 6 33 13 3...
input:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 2 3 1 4 2 5 1 6 4 7 2 8 6 9 1 10 6 11 2 12 10 13 2 14 2 15 1 16 6 17 11 18 10 19 16 20 6 21 16 22 2 23 4 24 22 25 6 26 2 27 10 28 2 29 4 30 16 31 7 32 6 33 13 3...
output:
2 5000 2853 1 2 1 4 1 802 1 1336 2 12 2 23 2 45 2 92 2 155 2 183 2 287 2 309 2 365 4 7 4 30 4 47 4 88 4 175 4 1335 4 4003 5 4002 6 17 6 21 6 33 6 41 6 51 6 101 6 161 6 251 6 401 6 801 6 1001 6 2001 6 4001 7 44 7 94 7 130 7 1334 8 3999 10 13 10 37 10 75 10 109 10 112 10 223 10 334 10 445 11 18 11 48 ...
input:
2 5000 2853 1 2 1 4 1 802 1 1336 2 12 2 23 2 45 2 92 2 155 2 183 2 287 2 309 2 365 4 7 4 30 4 47 4 88 4 175 4 1335 4 4003 5 4002 6 17 6 21 6 33 6 41 6 51 6 101 6 161 6 251 6 401 6 801 6 1001 6 2001 6 4001 7 44 7 94 7 130 7 1334 8 3999 10 13 10 37 10 75 10 109 10 112 10 223 10 334 10 445 11 18 11 48 ...
output:
08e2277017156c65e2df558ef1d27eae814767ea6a771d5be687d4040371b97399dd6bd28d5207cce21e4e205ea711c730f7ccf85a21af8c41bab7c037b89e9e 776337210
Subtask #2:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 0ms = 0ms + 0ms
memory: 1868kb,1812kb
input:
1 17476204
output:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 1 3 2 4 1 5 5 6 5 7 5 8 5 9 5 10 5 11 10 12 5 13 6 14 5 15 5 16 13 17 1 18 5 19 5 20 5 21 5 22 21 23 23 24 5 25 5 26 19 27 23 28 5 29 22 30 5 31 17 32 13 33 32 ...
input:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 1 3 2 4 1 5 5 6 5 7 5 8 5 9 5 10 5 11 10 12 5 13 6 14 5 15 5 16 13 17 1 18 5 19 5 20 5 21 5 22 21 23 23 24 5 25 5 26 19 27 23 28 5 29 22 30 5 31 17 32 13 33 32 ...
output:
2 5000 2853 1 2 1 18 1 35 1 69 2 4 2 322 4 1188 5 7 5 13 5 20 5 21 5 31 5 36 5 37 5 41 5 43 5 51 5 57 5 71 5 76 5 85 5 96 5 101 5 115 5 121 5 134 5 141 5 151 5 169 5 181 5 253 5 286 5 293 5 301 5 316 5 361 5 366 5 381 5 400 5 421 5 451 5 457 5 505 5 512 5 526 5 533 5 571 5 631 5 658 5 685 5 701 5 85...
input:
2 5000 2853 1 2 1 18 1 35 1 69 2 4 2 322 4 1188 5 7 5 13 5 20 5 21 5 31 5 36 5 37 5 41 5 43 5 51 5 57 5 71 5 76 5 85 5 96 5 101 5 115 5 121 5 134 5 141 5 151 5 169 5 181 5 253 5 286 5 293 5 301 5 316 5 361 5 366 5 381 5 400 5 421 5 451 5 457 5 505 5 512 5 526 5 533 5 571 5 631 5 658 5 685 5 701 5 85...
output:
08e2277017156c65e2df558ef1d27eae814767ea6a771d5be687d4040371b97399dd6bd28d5207cce21e4e205ea711c730f7ccf85a21af8c41bab7c037b89e9e 33212980512
Subtask #3:
score: 0
Wrong Answer
Test #25:
score: 0
Wrong Answer
time: 0ms = 0ms + 0ms
memory: 1868kb,1812kb
input:
1 355365355024496523
output:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 2 3 1 4 4 5 4 6 4 7 1 8 4 9 4 10 4 11 4 12 4 13 6 14 8 15 4 16 12 17 15 18 4 19 19 20 4 21 1 22 4 23 10 24 4 25 24 26 6 27 13 28 8 29 11 30 4 31 7 32 12 33 4 34...
input:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 2 3 1 4 4 5 4 6 4 7 1 8 4 9 4 10 4 11 4 12 4 13 6 14 8 15 4 16 12 17 15 18 4 19 19 20 4 21 1 22 4 23 10 24 4 25 24 26 6 27 13 28 8 29 11 30 4 31 7 32 12 33 4 34...
output:
2 5000 2853 1 2 1 4 1 380 1 2654 3 258 4 7 4 12 4 13 4 21 4 23 4 31 4 37 4 41 4 45 4 89 4 111 4 121 4 133 4 181 4 221 4 265 4 331 4 361 4 397 4 496 4 567 4 991 4 1321 4 1416 4 4246 6 54 6 107 6 690 6 1379 7 94 10 47 10 75 10 112 10 223 10 1703 10 2554 10 3819 11 30 12 17 12 33 15 18 15 122 15 188 15...
input:
2 5000 2853 1 2 1 4 1 380 1 2654 3 258 4 7 4 12 4 13 4 21 4 23 4 31 4 37 4 41 4 45 4 89 4 111 4 121 4 133 4 181 4 221 4 265 4 331 4 361 4 397 4 496 4 567 4 991 4 1321 4 1416 4 4246 6 54 6 107 6 690 6 1379 7 94 10 47 10 75 10 112 10 223 10 1703 10 2554 10 3819 11 30 12 17 12 33 15 18 15 122 15 188 15...
output:
08e2277017156c65e2df558ef1d27eae814767ea6a771d5be687d4040371b97399dd6bd28d5207cce21e4e205ea711c730f7ccf85a21af8c41bab7c037b89e9e 1818925983