6 条题解
-
3陈远秋 LV 10 @ 2018-10-27 14:54:24
n=int(input()) ans=0; for i in range(n): for j in range(i,n): k=n-i-j if(k<j):#循环枚举,利用if语句使k>j>i防止重复计数 continue if(i+j>k): ans+=1 print(ans)
-
22018-12-14 19:44:01@
l=int(input())
a=b=n=0
for a in range(1,l):
for b in range(1,l-a):
c=l-a-b
if b<=a and c<=b:
if a+b>c and a+c>b and b+c>a:
n=n+1
print(n) -
12019-04-13 22:13:29@
一个比较奇怪的做法
n=int(input())
p=(n+1)//2
k=0
for a in range(0,p):
for b in range(0,p):
c=n-a-b
if a+b>c and c>0 and b>0 and a>0:if a==b:
if b==c:
k=k+6
else:
k=k+2
elif a==c and c!=b:
k=k+2
elif c==b and c!=a:
k=k+2
else:
k=k+1
p=k//6
print(p) -
02019-04-18 10:04:41@
#include <iostream> #include <stdlib.h> using namespace std; int main() { int n; cin >> n; int ans = 0; for(int i = 1; i <= n/2 - (!(n % 2)); i++) { for(int j = 1; j <= i; j++) { int k = n - i - j; if(k > j) { continue; } else ans++; } } cout << ans; return 0; }
-
02018-11-02 13:52:47@
n=int(input()) cnt=0 for i in range(n//2+1): for j in range(i,n//2+1): if i+j>n-i-j and n-i-j>=j: cnt+=1 print(cnt)
-
02018-10-30 17:47:00@
#include <stdio.h> #include<iostream> using namespace std; int n,cnt; int main() { cin>>n; for(int i=1;i<=n/2-(!(n%2));i++) { for(int j=1;j<=i;j++) { int k=n-i-j; if(k>j)continue; cnt++; } } cout<<cnt; }
- 1
信息
- 难度
- 6
- 分类
- (无)
- 标签
- (无)
- 递交数
- 2705
- 已通过
- 770
- 通过率
- 28%
- 被复制
- 2
- 上传者