QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#799358#100. TetrahedronspeimudaAC ✓2050ms128612kbC++11885b2024-12-05 11:59:552024-12-05 11:59:56

Judging History

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

  • [2024-12-05 11:59:56]
  • 评测
  • 测评结果:AC
  • 用时:2050ms
  • 内存:128612kb
  • [2024-12-05 11:59:55]
  • 提交

answer

#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#define pr pair
#define f first
#define s second
#define ll unsigned long long
#define mp make_pair
#define pll pr<ll,ll>
#define pii pr<int,int>
#define piii pr<int,pii>
using namespace std;
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
ll gt[16000007];
int main()
{
	ios_base::sync_with_stdio(0);
	ll n;
	cin>>n;
	ll g=6*(n-1),h=n-1;
	ll ans=g*(g-1)*(g-2)*(g-3)/24;
	ans-=h*(h-1)*(h-2)*(h-3)/4;
	ans-=(h-1)*h*h*h*6;
	ans-=(h-2)*(h-1)*h*h*5;
	ans-=(h-1)*(h-1)*h*h*3;
	int z=0;
	for(int i=1;i<n;i++) for(int j=1;j<n;j++)
	{
		int fa=(n-i)*j,fb=i*(n-j);
		int d=gcd(fa,fb);
		fa/=d;
		fb/=d;
		gt[z++]=((ll)fa)<<30|fb;
	}
	sort(gt,gt+z);
	for(int i=0;i<z;)
	{
		int j=i;
		for(;j<z;j++) if(gt[j]!=gt[i]) break;
		ans-=3ll*(j-i)*(j-i);
		i=j;
	}
	cout<<ans<<endl;
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3660kb

input:

2

output:

12

result:

ok 1 number(s): "12"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3660kb

input:

37

output:

65561472

result:

ok 1 number(s): "65561472"

Test #3:

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

input:

3

output:

417

result:

ok 1 number(s): "417"

Test #4:

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

input:

4

output:

2481

result:

ok 1 number(s): "2481"

Test #5:

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

input:

5

output:

8448

result:

ok 1 number(s): "8448"

Test #6:

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

input:

6

output:

21492

result:

ok 1 number(s): "21492"

Test #7:

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

input:

7

output:

45765

result:

ok 1 number(s): "45765"

Test #8:

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

input:

8

output:

86349

result:

ok 1 number(s): "86349"

Test #9:

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

input:

9

output:

149280

result:

ok 1 number(s): "149280"

Test #10:

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

input:

10

output:

241548

result:

ok 1 number(s): "241548"

Test #11:

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

input:

11

output:

371121

result:

ok 1 number(s): "371121"

Test #12:

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

input:

12

output:

547137

result:

ok 1 number(s): "547137"

Test #13:

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

input:

13

output:

778968

result:

ok 1 number(s): "778968"

Test #14:

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

input:

14

output:

1077852

result:

ok 1 number(s): "1077852"

Test #15:

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

input:

15

output:

1455501

result:

ok 1 number(s): "1455501"

Test #16:

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

input:

16

output:

1924269

result:

ok 1 number(s): "1924269"

Test #17:

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

input:

17

output:

2498208

result:

ok 1 number(s): "2498208"

Test #18:

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

input:

18

output:

3192204

result:

ok 1 number(s): "3192204"

Test #19:

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

input:

19

output:

4021137

result:

ok 1 number(s): "4021137"

Test #20:

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

input:

20

output:

5002401

result:

ok 1 number(s): "5002401"

Test #21:

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

input:

21

output:

6152520

result:

ok 1 number(s): "6152520"

Test #22:

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

input:

22

output:

7490148

result:

ok 1 number(s): "7490148"

Test #23:

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

input:

23

output:

9035637

result:

ok 1 number(s): "9035637"

Test #24:

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

input:

24

output:

10808829

result:

ok 1 number(s): "10808829"

Test #25:

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

input:

25

output:

12830472

result:

ok 1 number(s): "12830472"

Test #26:

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

input:

26

output:

15122892

result:

ok 1 number(s): "15122892"

Test #27:

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

input:

27

output:

17710593

result:

ok 1 number(s): "17710593"

Test #28:

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

input:

28

output:

20615985

result:

ok 1 number(s): "20615985"

Test #29:

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

input:

29

output:

23865144

result:

ok 1 number(s): "23865144"

Test #30:

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

input:

30

output:

27485172

result:

ok 1 number(s): "27485172"

Test #31:

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

input:

31

output:

31500117

result:

ok 1 number(s): "31500117"

Test #32:

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

input:

32

output:

35941269

result:

ok 1 number(s): "35941269"

Test #33:

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

input:

33

output:

40835784

result:

ok 1 number(s): "40835784"

Test #34:

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

input:

34

output:

46213188

result:

ok 1 number(s): "46213188"

Test #35:

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

input:

35

output:

52106697

result:

ok 1 number(s): "52106697"

Test #36:

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

input:

36

output:

58545057

result:

ok 1 number(s): "58545057"

Test #37:

score: 0
Accepted
time: 2050ms
memory: 128612kb

input:

4000

output:

10164196900132989

result:

ok 1 number(s): "10164196900132989"

Test #38:

score: 0
Accepted
time: 1280ms
memory: 83800kb

input:

3172

output:

4018224734920449

result:

ok 1 number(s): "4018224734920449"

Test #39:

score: 0
Accepted
time: 155ms
memory: 15608kb

input:

1194

output:

80475788752884

result:

ok 1 number(s): "80475788752884"

Test #40:

score: 0
Accepted
time: 25ms
memory: 7328kb

input:

479

output:

2072359159125

result:

ok 1 number(s): "2072359159125"

Test #41:

score: 0
Accepted
time: 2ms
memory: 5756kb

input:

126

output:

9654636228

result:

ok 1 number(s): "9654636228"

Test #42:

score: 0
Accepted
time: 74ms
memory: 9112kb

input:

822

output:

18045550290852

result:

ok 1 number(s): "18045550290852"

Test #43:

score: 0
Accepted
time: 1071ms
memory: 72412kb

input:

2928

output:

2916975738011877

result:

ok 1 number(s): "2916975738011877"

Test #44:

score: 0
Accepted
time: 185ms
memory: 16444kb

input:

1274

output:

104335421693580

result:

ok 1 number(s): "104335421693580"

Test #45:

score: 0
Accepted
time: 454ms
memory: 34228kb

input:

1921

output:

540003893401944

result:

ok 1 number(s): "540003893401944"

Test #46:

score: 0
Accepted
time: 1239ms
memory: 81076kb

input:

3110

output:

3713046514992948

result:

ok 1 number(s): "3713046514992948"

Test #47:

score: 0
Accepted
time: 48ms
memory: 8128kb

input:

691

output:

9001799196273

result:

ok 1 number(s): "9001799196273"

Test #48:

score: 0
Accepted
time: 128ms
memory: 13588kb

input:

1066

output:

51106224390756

result:

ok 1 number(s): "51106224390756"

Test #49:

score: 0
Accepted
time: 7ms
memory: 5700kb

input:

268

output:

201528266361

result:

ok 1 number(s): "201528266361"

Test #50:

score: 0
Accepted
time: 899ms
memory: 60432kb

input:

2659

output:

1983591305458065

result:

ok 1 number(s): "1983591305458065"

Test #51:

score: 0
Accepted
time: 76ms
memory: 9596kb

input:

860

output:

21626448033225

result:

ok 1 number(s): "21626448033225"

Test #52:

score: 0
Accepted
time: 10ms
memory: 4444kb

input:

314

output:

380734623660

result:

ok 1 number(s): "380734623660"

Test #53:

score: 0
Accepted
time: 449ms
memory: 34172kb

input:

1921

output:

540003893401944

result:

ok 1 number(s): "540003893401944"

Test #54:

score: 0
Accepted
time: 1273ms
memory: 83880kb

input:

3172

output:

4018224734920449

result:

ok 1 number(s): "4018224734920449"

Test #55:

score: 0
Accepted
time: 280ms
memory: 22712kb

input:

1560

output:

234716061994797

result:

ok 1 number(s): "234716061994797"

Test #56:

score: 0
Accepted
time: 86ms
memory: 10348kb

input:

888

output:

24587664242733

result:

ok 1 number(s): "24587664242733"

Test #57:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

75

output:

1181582409

result:

ok 1 number(s): "1181582409"

Test #58:

score: 0
Accepted
time: 1776ms
memory: 109804kb

input:

3685

output:

7320487107861408

result:

ok 1 number(s): "7320487107861408"

Test #59:

score: 0
Accepted
time: 963ms
memory: 63352kb

input:

2762

output:

2309414180449836

result:

ok 1 number(s): "2309414180449836"

Test #60:

score: 0
Accepted
time: 478ms
memory: 36140kb

input:

1994

output:

626940735928284

result:

ok 1 number(s): "626940735928284"

Test #61:

score: 0
Accepted
time: 366ms
memory: 28016kb

input:

1764

output:

383873642612793

result:

ok 1 number(s): "383873642612793"

Test #62:

score: 0
Accepted
time: 6ms
memory: 4140kb

input:

247

output:

145191715389

result:

ok 1 number(s): "145191715389"