QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#420302#2817. 鸽鸽的分割liqingyang#AC ✓0ms3660kbC++17307b2024-05-24 16:21:012024-05-24 16:21:05

Judging History

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

  • [2024-05-24 16:21:05]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3660kb
  • [2024-05-24 16:21:01]
  • 提交

answer

#include<iostream>
using namespace std;
int n;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(cin>>n)
	{
		int ans=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=i+2;j<=n;j++)
			{
				ans+=(j-i-1)*(n-(j-i+1));
			}
		}
		cout<<(ans>>1)+(n*(n-1)>>1)+1<<endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

0
1
2
3
4
5
6
7
8
9
10
20
30
40
50
60
61
62
63
64

output:

1
1
2
4
8
16
31
57
99
163
256
5036
27841
92171
231526
489406
523686
559737
597619
637393

result:

ok 20 lines