把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. Git版本控制工具(三)----远程仓库GitHub的使用

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...

  2. static,静态关键字的详解

    一,使用static声明属性 class Person{ // 定义Person类 String name ; // 定义name属性,暂时不封装 int age ; // 定义age属性,暂时不封装 ...

  3. ubuntu 查看软件包版本以及软件包的源码

    aptitude show  xxx sudo apt-cache show autoconf setattr, getattr, setattr http://ju.outofmemory.cn/e ...

  4. google project tango 学习笔记

    google io 2015上 project tango 的演示视频

  5. Python高手之路【八】python基础之requests模块

    1.Requests模块说明 Requests 是使用 Apache2 Licensed 许可证的 HTTP 库.用 Python 编写,真正的为人类着想. Python 标准库中的 urllib2  ...

  6. OAF与XML Publisher集成(转)

    原文地址:OAF与XML Publisher集成 有两种方式,一种是用VO与XML Publisher集成,另一种是用PL/SQL与XML Publisher集成 用VO与XML Publisher集 ...

  7. HMAC-MD5算法原理及实现

    以下是分析节选,对于更详细的描述可以查阅RFC2104文档.     HMAC需要一个加密用散列函数(表示为H)和一个密钥K. 假设H是一个将数据块用一个基本的迭代压缩函数来加密的散列函数. 用B来表 ...

  8. JS 之性能优化(1)

    了解JS性能优化是学习前端必备的一项技能.下面就简单的列出几点: 1.注意作用域,避免全局查找. 访问全局变量比访问局部变量慢,是因为需要遍历作用域链,查找作用域链需要额外的时间.所以在一个函数中,将 ...

  9. [CareerCup] 5.3 Next Binary Representation 下一个二进制表达

    5.3 Given a positive integer, print the next smallest and the next largest number that have the same ...

  10. Linux及安全——ELF实践

    Linux及安全——ELF实践  一.分析ELF文件头 二.通过文件头找到section header table,理解内容 三.通过section header table 找到各section 四 ...