首页 > 编程语言 > 详细

算法竞赛入门经典 写题笔记(第二章 数学基础)

时间:2019-04-14 11:24:51      阅读:140      评论:0      收藏:0      [点我收藏+]

Chess Queen

组合数

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define MAXN 100010
using namespace std;
int n,m;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("ce.in","r",stdin);
    #endif
    while(scanf("%d%d",&n,&m)==2)
    {
        if(n==0&&m==0) break;
        long long cur_ans=0;
        if(n>m) swap(n,m);
        for(int i=1;i<=n-1;i++) cur_ans+=1ll*i*(i-1);
        // printf("cur_ans=%lld\n",cur_ans);
        printf("%lld\n",1ll*(cur_ans)*4+1ll*n*m*(n+m-2)+1ll*2*(m-n+1)*n*(n-1));
    }
    return 0;
}

例题2 Triangle Counting

例题3 Cheerleaders

例题4 Exploring Pyramids

例题5 Investigating Div-Sum Property

例题6 Glenbow Museum

例题6 Series-Parallel Networks

例题7 Always an integer

例题8 GCD - Extreme (II)

例题9 Code Feat

例题10 Emoogle Grid

例题11 Playing With Stones

例题12 Treblecross

例题13 Tribles

例题14 Joining with Friend

例题15 Expect the Expected

例题16 Race to 1

例题17 Arif in Dhaka (First Love Part 2)

例题18 Leonardo‘s Notebook

例题19 Find the Permutations

例题20 Pixel Shuffle

例题21 Recurrences

例题22 Cellular Automaton

例题23 Back to Kernighan-Ritchie

例题24 Square

例题25 solve It

算法竞赛入门经典 写题笔记(第二章 数学基础)

原文:https://www.cnblogs.com/fengxunling/p/10697977.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!