1 solutions

  • 0
    @ 2023-12-3 21:35:24

    C++ :

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    
    int main()
    {
    	long long n;
    	//freopen("tri.in","r",stdin);
    	//freopen("tri.out","w",stdout);
    	while(scanf("%lld",&n) != EOF) {
    		long long len = (n - 1 - (n + 1) / 2);//固定任意一点,设这点对应的点为直角或者钝角三角形,则该店对应的圆弧长度至少为(n + 1) / 2,对于某个长度为i的
    						      //其个数为(n - 1 - i),因为圆弧长度为(n + 1) / 2 ... (n - 2) 个数分别为(n - 1 -  (n - 2)) + (n - 1 - (n - 3))...
    						      //(n - 1 - (n + 1) / 2) ,划开即是1,2,3...(n - 1 - len),等差数列求和,有(len + 1) * len / 2LL,因为圆上N点等价,
    						      //所以直或者钝角的个数要*N,总三角形数为C(N , 3),减去N * len * (len + 1) / 2就是结果
    		long long ans = n * (n - 1) * (n - 2) / 6LL - n * len * (len + 1) / 2LL;
    		printf("%lld\n",ans);
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    1315
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By