Codeforces Round #368 (Div. 2) C
来源:互联网 发布:python中split函数 编辑:程序博客网 时间:2024/05/17 22:59
题目链接:CF 368 DIV2 C
题意给定一个n(n>=1&&n<=1e9),找它的勾股数,不存在输出-1,;
AC code:
#include<iostream>#include<cstring>#include<cstdio>#include<algorithm>#include<queue>#include<stack>#include<cmath>#include<limits>#include<string>using namespace std;#define LL __int64#define debug 0#define T(a, b) (((a) * (a))/(b))LL caseNum,n,v;void Do(){ if(n == 1 || n == 2){printf("-1\n");return;}if(n % 2 == 1){printf("%I64d %I64d\n", n * n / 2, n * n / 2 + 1);return;}else{if(n % 4 == 0){printf("%I64d %I64d\n", 3 * n / 4, 5 * n / 4);}else{printf("%I64d %I64d\n", 2 * T(n / 2, 2),2 * (T(n / 2, 2) + 1));}}}int main(){#if debug freopen("in.txt","r",stdin);#endif // debug while(~scanf("%I64d", &n)) { Do(); } return 0;}
1 0
- Codeforces Round #368 (Div. 2) C
- Codeforces Round #368 (Div. 2) A C
- CF707C(Codeforces Round #368 (Div. 2) - C)
- 【Codeforces Round #368 (Div. 2)】Codeforces 707C Pythagorean Triples
- 【codeforces】Codeforces Round #370 (Div. 2) C
- Codeforces Round #368 (DIV 2)
- Codeforces Round #368 (Div. 2)
- Codeforces Round #368 (Div. 2)
- Codeforces Round #368 (Div. 2)
- Codeforces Round #368 (Div. 2)
- Codeforces Round #368 (Div. 2)
- Codeforces Round #368 (Div. 2)
- Codeforces Round #368 (Div. 2)
- Codeforces Round #368 (Div.2)
- Codeforces Round #368 (Div. 2)
- Codeforces Round #368 (Div. 2)
- Codeforces Round #368 (Div. 2)
- Codeforces Round #368 (Div. 2) -- C. Pythagorean Triples (数学公式)
- mini2451上madplayer的移植
- Spark 大数据中文分词统计(三) Scala语言实现分词统计
- 一步一步的来封装自己的RecycleView
- Oracle 数据库中的索引
- 【Leetcode】110. Balanced Binary Tree 【DFS】
- Codeforces Round #368 (Div. 2) C
- B树、B-树、B+树、B*树
- android:ellipsize的使用
- jsp与servlet
- Struts2框架9.拦截器配置
- iOS swift-UIView随键盘弹出/隐藏而改变位置
- Python的各种解释器实现CPython | PyPy | Jython | IronPython等
- 正则表达式与grep、sed
- POJ 2299 Ultra-QuickSort