把1到n*n填在n*n的格子里。要求每一行都是递增的,使第k列的和最大。

分析

第k列前的格子1 2 .. 按要求填到满格,然后第k列及后面的格子,都从左到右填递增1的数。

第k列的和再加起来,我很矫情地求了公式=_=

代码

#include<cstdio>
int n,k;
int a[][];
int main()
{
scanf("%d%d",&n,&k);
int m=; for(int i=; i<=n; i++)
for(int j=; j<k; j++)
{
a[i][j]=m++;
}
for(int i=; i<=n; i++)
for(int j=k; j<=n; j++)
{
a[i][j]=m++;
}
printf("%d\n",(n*(n-+k)+k+)*n/);
for(int i=; i<=n; i++)
{
for(int j=; j<=n; j++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
return ;
}

【CodeForces 625C】K-special Tables的更多相关文章

  1. 【77.78%】【codeforces 625C】K-special Tables

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  2. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  3. 【39.66%】【codeforces 740C】Alyona and mex

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. 【codeforces 755A】PolandBall and Hypothesis

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 【13.77%】【codeforces 734C】Anton and Making Potions

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【27.40%】【codeforces 599D】Spongebob and Squares

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. 【codeforces 749B】Parallelogram is Back

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  9. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

随机推荐

  1. Linux安装telnet

    安装环境:CentOS 6.4    上篇已经讲述了memcached的安装,现在要测试Memcached功能的时候,需要使用到telnet服务.于是就有了本篇.   一.安装telnet 1.检测t ...

  2. EmberJS路由详解

    配置路由器,ember中是根据路径寻找与路由名相对应的模板和控制器的,比如当访问http://localhost:80/这个网址的时候,ember框架会自动寻找与路由名post相对应的PostTemp ...

  3. 使用CuteSlider做网站炫酷的幻灯片

    cuteSlider 1.预览 官网:http://www.cuteslider.com/ 应用:http://www.dutphonelab.org/ 2.资料 文档:http://pan.baid ...

  4. 12Spring_AOP编程(AspectJ)_前置通知

    接下里的博客会一篇一篇的讲解每一个通知.其实AOP_AspectJ的编程与传统的AOP的编程的最大的区别就是写一个Aspect 支持多个Advice和多个PointCut .而且我们写AOP_Aspc ...

  5. Elasticsearch集群中处理大型日志流的几个常用概念

    之前对于CDN的日志处理模型是从logstash agent==>>redis==>>logstash index==>>elasticsearch==>&g ...

  6. Java连接Elasticsearch集群

    package cn.test; import java.net.InetAddress; import java.net.UnknownHostException; import org.elast ...

  7. C语言 Linux内核链表(企业级链表)

    //Linux内核链表(企业级链表) #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> ...

  8. JS replace()方法-字符串首字母大写

    replace() 方法用于在字符串中用一些字符替换另一些字符,或替换一个与正则表达式匹配的子串. replace()方法有两个参数,第一个参数是正则表达式,正则表达式如果带全局标志/g,则是代表替换 ...

  9. [CareerCup] 4.6 Find Next Node in a BST 寻找二叉搜索树中下一个节点

    4.6 Write an algorithm to find the'next'node (i.e., in-order successor) of a given node in a binary ...

  10. Bootstrap 表格

    Bootstrap 提供了一个清晰的创建表格的布局.下表列出了 Bootstrap 支持的一些表格元素: 标签 描述 <table> 为表格添加基础样式. <thead> 表格 ...