UVa 10790 - How Many Points of Intersection?
来源:互联网 发布:mac装双系统好吗 编辑:程序博客网 时间:2024/04/29 04:19
传送门UVa 10790 - How Many Points of Intersection?
题目挺简单, 观察一下就可以得出规律num = n * (n - 1) * m * (m - 1) / 4;
题目要求用long long输出... 于是我就声明了一个变量
long long sum
然后用
int m, n;接收.
可是这样一来就错了...
后来求助了失踪同学, 了解到如果用int类型的m, n, 在计算n * (n - 1) * m * (m - 1) / 4就会溢出了.
涨姿势了..
#include <cstdio>#include <cmath>using namespace std;int main(){ //freopen("input.txt", "r", stdin); long long m, n; long long sum; int count = 1; int i, j; while (scanf("%lld%lld", &m, &n)) { sum = 0; if (m == 0 && n == 0) break; sum = n * (n - 1) * m * (m - 1) / 4; printf("Case %d: %lld\n", count++, sum); } return 0;}
0 0
- UVa 10790 How Many Points of Intersection?
- uva 10790 How Many Points of Intersection?
- uva 10790 - How Many Points of Intersection?
- uva-10790-How Many Points of Intersection?
- UVa 10790 - How Many Points of Intersection?
- Uva 10790 - How Many Points of Intersection?
- UVa 10790 - How Many Points of Intersection?
- UVA 10790 How Many Points of Intersection?
- uva 10790 - How Many Points of Intersection
- uva 10790 How Many Points of Intersection?
- UVa 10790 How Many Points of Intersection?
- uva - 10790 - How Many Points of Intersection?
- UVa 10790 - How Many Points of Intersection?
- UVa 10790 - How Many Points of Intersection?
- Uva 10790 How Many Points of Intersection?
- UVA - 10790 How Many Points of Intersection?
- UVA - 10790 How Many Points of Intersection?
- uva 10790 How Many Points of Intersection?
- jquery学习笔记
- 俄罗斯,一个爱阅读的民族——从电影《夺命地铁》(俄罗斯,2013)谈起
- sql导数据问题
- maven
- 二分图最大匹配 匈牙利算法的简单理解
- UVa 10790 - How Many Points of Intersection?
- 黑马程序员 第24天 package
- VBox不可执行的解决方案
- java中equal和==的比较
- FL2440挂载U盘的方法
- ARM汇编 C语言 C++ 相互调用
- win8系统下安装SQL2005(SQL Server 2005)图文教程
- maven常用命令介绍
- OMNET++ libstdc++-6