UVA 10790 How Many Points of Intersection?
2016-07-15 19:45
337 查看
UVA-10790
题意:给出n,m,表示上面一条线有n个点,下面有m个点,上下的点相互连接,求交点的数量。解题思路:先把上面的点摆好,下面第一个个点进去有 0 个交点,第二个点进去有 n-1 + n-2 + n-3 ……+1个交点,第三个点进去有 2*( n-1 + n-2 + n-3 + ……+ 1) ,到第m个进去有 (m-1)*(1+2+……+n-1) 。和为(1+2+3+……+n-1)*(1+2+3+……+m-1) 。套等差数列球和。
/************************************************************************* > File Name: UVA-10790.cpp > Author: Narsh > > Created Time: 2016年07月15日 星期五 09时13分16秒 ************************************************************************/ #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> using namespace std; int main () { long long n,m,num=0; while (cin>>n>>m && n+m) { printf("Case %lld: ",++num); cout<<n*(n-1)*m*(m-1)/4LL<<endl; } }
相关文章推荐
- oracle到kafka的同步
- memcpy与strcpy区别,memcmp与strcmp的区别
- Spark性能优化2
- 【AD】WinXP Win7x86/x64 自动加域脚本 更新20151109
- c#——Winform DatagridView上显示下拉树
- C语言中常用的函数及注意事项
- 常用Maven插件介绍_继续更新
- 第二天的标题估计也被吃了
- Android App 内存泄露之Handler
- Tesseract-OCR图像识别引擎 windows10使用方法入门
- VC6命令行编译DLL
- **PHP** 文件操作
- Nexus搭建Maven私服
- Android12个重要知识点(2)
- EasyIPCamera高性能摄像机RTSP服务器RTSPServer解决方案
- EasyIPCamera高性能摄像机RTSP服务器RTSPServer解决方案
- 十六进制转byte变负数
- 回家【推荐】
- 手持两把锟斤拷,口中疾呼烫烫烫。脚踏千朵屯屯屯,笑看万物锘锘锘
- [个人博客搬运]Effective Objective-C 2.0知识点小记