10790 How Many Points of Intersection?

很久不做题了,做也做水题,做水题也做不出,想很久没想出来,看了一下别人的blog,

可以这么想,要产生一个交点至少要上下各两个点,这样答案出来了,上面有(a-1)*a/2种,同理下面也是,这样就得到答案了

 1 #include <cstdio>
 2 #include <iostream>
 3 using namespace std;
 4 
 5     int
 6 main ( int argc, char *argv[] )
 7 {
 8     freopen("data","r",stdin);
 9     long long int a,b;
10     int Case = 1;
11     while(scanf("%lld %lld",&a,&b)){
12         if(a+b == 0)
13         {
14             break;
15         }
16         cout<<"Case "<<Case++<<": ";
17         cout<<((a-1)*a*(b-1)*b)/4<<endl;
18     }
19 
20     return 0;
21 }                /* ----------  end of function main  ---------- */
原文地址:https://www.cnblogs.com/UnGeek/p/2722905.html