GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — awesome-algorithm/src/xunlei.md at master · cookie220/awesome-algorithm

Expand file tree

/

xunlei.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
49 lines (39 loc) · 943 Bytes
/

xunlei.md

Copy path

File metadata and controls

49 lines (39 loc) · 943 Bytes
Raw
Copy raw file
Download raw file
Edit and raw actions
"""第一题"""
N = int(input())


def gcd(big, small):
    if big < small:
        small, big = big, small
    remainder = big % small
    if remainder == 0:
        return small
    else:
         return gcd(small,remainder)

res = 0
from math import sqrt
for c in range(1, N+1):
    for a in range(1, c):
        for b in range(max(c-a+1,a), c):
            if a * a + b * b == c * c:
                if gcd(a, b) == 1 and gcd(b, c) == 1 and gcd(a, c) == 1:
                    res += 1
                    # print(a,b,c)

print(res)


"""第二题"""
tmp = input().split()
positive, negative = int(tmp[0]), int(tmp[1])
# print(positive, negative)

idx = 0
for i in range(6, -1, -1):
    if i*positive+(7-i)*negative < 0:
        idx = i
        break
# print(idx)


res = (negative*(7-idx)+positive*idx) * 2
# print(res)
if idx >= 3:
    res += 3 * positive
else:
    res += idx * positive + (3 - idx) * negative

print(res)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.