CF1971F Circle Perimeter
1.CF1971F Circle Perimeter
2.GCD构造排列3.拓扑排序4.窗口判断子数组排列5.前缀和解决字符串变化问题6.CF1881D 质因数分解与重新分配7.CF1913C Game with Multiset题目
Given an integer
A lattice point is a point with integer coordinates. The Euclidean distance from
https://codeforces.com/contest/1971/problem/F
Input
The first line contains a single integer
The sum of
6
1
2
3
4
5
1984
Output
For each test case, output a single integer — the number of lattice points that have an Euclidean distance
8
16
20
24
40
12504
题解
解题思路
注意到数据范围为1e5级别,需要线性时间复杂度,故考虑枚举一个数并快速算出另外一个数
对公式
Code
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(nullptr);
using namespace std;
typedef long long LL;
signed main(){
IOS;
int _;cin>>_;
while(_--){
LL n;cin>>n;
LL ans=0;
for(LL i= -n;i<=n;i++){
LL t1=ceil(sqrtl(n*n-i*i));
LL t2=sqrtl((n+1)*(n+1)-i*i-1);
ans+=(t2-t1+1)*2-(t1==0);
}
cout<<ans<<endl;
}
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】