暴力 Codeforces Round #183 (Div. 2) A. Pythagorean Theorem II
题目传送门
1 /* 2 暴力:O (n^2) 3 */ 4 #include <cstdio> 5 #include <algorithm> 6 #include <cstring> 7 #include <cmath> 8 #include <vector> 9 using namespace std; 10 11 const int MAXN = 1e4 + 10; 12 const int INF = 0x3f3f3f3f; 13 14 int main(void) //Codeforces Round #183 (Div. 2) A. Pythagorean Theorem II 15 { 16 int n; 17 while (scanf ("%d", &n) == 1) 18 { 19 int ans = 0; 20 for (int i=1; i<=n; ++i) 21 { 22 for (int j=i; j<=n; ++j) 23 { 24 if (i * i + j * j > n * n) break; 25 int c = sqrt (i * i + j * j); 26 if (c <= n && c * c == i * i + j * j) ans++; 27 } 28 } 29 30 printf ("%d\n", ans); 31 } 32 33 return 0; 34 }
转载于:https://www.cnblogs.com/Running-Time/p/4556853.html
暴力 Codeforces Round #183 (Div. 2) A. Pythagorean Theorem II相关推荐
- Codeforces Round #183 (Div. 2)
A. Pythagorean Theorem II 暴力,\(O(n^2)\). B. Calendar 每个日期计算到0年1月1日的天数,相当于转化成前缀和形式. 闰年数计算\[\lfloor\fr ...
- Codeforces Round #368 (Div. 2) C. Pythagorean Triples
题目链接:http://codeforces.com/contest/707/problem/C 题意: 直角三角形的三边都为整数,给出其中一边n,求另外两边m.k. (1 ≤ n ≤ 109) ( ...
- Codeforces Round #183 (Div. 2) C
思维题,想到就秒杀,没想到或者想错方向了那么就完蛋了 0 1 2 3 4 1 2 3 4 0 你就会发现是可以的. 我经历了很久错误的思维,找到了一些性质 1. ai+bi的和一定为一串从(n/2) ...
- 暴力+构造 Codeforces Round #283 (Div. 2) C. Removing Columns
题目传送门 1 /* 2 题意:删除若干行,使得n行字符串成递增排序 3 暴力+构造:从前往后枚举列,当之前的顺序已经正确时,之后就不用考虑了,这样删列最小 4 */ 5 /************* ...
- Codeforces Round #743 (Div. 2) E. Paint 区间dp + 暴力
传送门 文章目录 题意: 思路: 题意: 给你一个有nnn个像素的图像,每个像素都有一个颜色aia_iai,保证每种颜色的图像不会超过202020个.你现在每次可以选择一个颜色,并选择一段连续的像素 ...
- Codeforces Round #588 (Div. 2) E. Kamil and Making a Stream 数学 + 暴力
传送门 文章目录 题意: 思路: 题意: 给你一颗树,其中根是111,每个点有一个点权,求每个点到根的所有路径的gcdgcdgcd之和. n≤1e5n\le1e5n≤1e5 思路: 一看到以为是个点分 ...
- Codeforces Round #593 (Div. 2) D. Alice and the Doll 暴力 + 二分
传送门 文章目录 题意: 思路: 题意: 思路: 还以为这个题有什么高深的算法,结果就是个暴力. 由于n∗mn*mn∗m达到了1e101e101e10的级别,所以直接暴力肯定是不行的,考虑有很多空格, ...
- Codeforces Round #271 (Div. 2) C. Captain Marmot (暴力枚举+正方形判定)
题目链接:Codeforces Round #271 (Div. 2) C. Captain Marmot 题意:给4行数据,每行2个点.(x,y).(a,b).意思是(x,y)绕(a,b)逆时针旋转 ...
- Codeforces Round #636 (Div. 3) F. Restore the Permutation by Sorted Segments 思维 + 暴力
传送门 文章目录 题意: 思路: 题意: n≤200n\le200n≤200 思路: 首先关注到rrr从[2,n][2,n][2,n]都出现一次,所以很明显最后一个位置只出现一次,但是这样倒着来不是很 ...
最新文章
- solaris下ftp配置说明
- android考勤系统,Android端实现考勤管理系统
- .NET C#使用微信公众号登录网站
- 快速查找无序数组中的第K大数?
- VNCServer 配置
- $router和$route的区别
- Linux 安装 Pycharm
- ssms 缺少索引信息_搜索引擎整合营销
- 用MFC消息映射机制自定义消息
- Qt5学习笔记之bin文件合成工具二:bin文件的读取和写入
- JavaWeb之JSP技术总结
- 程序阻碍OD调试的方式1
- mysql field in set_MySQL中的find_in_set()函数使用技巧心得与应用场景总结
- php更换banner图片,jQuery简单实现banner图片切换
- 流利阅读12.18 Coffee or tea? The answer might be in your genes
- java读取cmyk_用于检测CMYK图像的JAI ImageIO的纯Java替代品
- 科研写作——常见句式(六)
- 简明介绍 n-gram
- 八皇后问题理解与解决
- autoIT 自动化上传/下载文件图文详解【python selenium】