uva 1549 - Lattice Point(暴力)
来源:互联网 发布:王者挂机软件 编辑:程序博客网 时间:2024/06/09 01:00
题目链接:uva 1549 - Lattice Point
题目大意:给定圆半径,以原点为圆心,求园内有多少个整数点。
解题思路:首先坐标轴将圆分成4份,所以只要单独考虑每一块的个数乘4再加1即可(原点)
#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const double pi = 4 * atan(1.0);typedef long long ll;ll solve (ll R) { ll ret = 0; ll r = R, M = R * R; for (ll i = 0; i <= R; i++) { while (r * r + i * i > M) r--; ret += r; } return 4 * ret + 1;}int main () { ll n; while (scanf("%lld", &n) == 1) { printf("%lld\n%lld\n", n, solve(n)); } return 0;}
1 0
- uva 1549 - Lattice Point(暴力)
- uva 687 - Lattice Practices(暴力)
- UVa 11768 Lattice Point or Not
- Uva-11768 Lattice Point or Not(欧扩)
- Uva-11768 Lattice Point or Not题解
- UVA 11768 Lattice Point or Not(扩展欧几里得)
- UVA 11768 - Lattice Point or Not(数论)
- UVA - 11768 Lattice Point or Not (拓展gcd)
- UVa 11768 Lattice Point or Not (扩展欧几里得)
- UVA 687 - Lattice Practices(暴力枚举+位运算)
- UVA 11809 Floating-Point Numbers(暴力)
- Lattice Point or Not
- UVa 1602 Lattice Animals
- UVA 1062 Lattice Animals
- Lattice Animals UVA
- uva 1602 Lattice Animals
- uva11768 - Lattice Point or Not 扩展gcd
- [poj 3090]Visible Lattice Point[欧拉函数]
- HDU--1026:Ignatius and the Princess I (BFS+优先队列+打印路径)
- HDU- 3549-Flow Problem (网络流之 EK)
- 1408181911-hd-A+B for Input-Output Practice (VII).cpp
- DLNA介绍
- iOS开发-时间设置NSDate
- uva 1549 - Lattice Point(暴力)
- c语言相关文件的输入和输出
- hdu 4348 可持续化线段树
- Android开机和关机广播监听
- 组队赛第六场:贪心+RMQ加二分
- 关于Linux Grep命令使用的详细介绍
- PyQT实现菜单中的复制,全选和清空的功能
- 解决Oracle11g空表无法导出的问题
- poj1185炮兵布阵结题报告--初步了解--状态压缩dp