把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. Zero

    Zero是我的极品现任BOSS曾用过的QQ昵称.那时候,我正跟京姑娘闹七年之痒,甩她而去赋闲在老家.Zero通过朋友介绍,看了我几篇零散的博客,就给我打电话,让我过来聊聊.本来我跟京姑娘也没有大矛盾, ...

  2. 第17章 内存映射文件(3)_稀疏文件(Sparse File)

    17.8 稀疏调拨的内存映射文件 17.8.1 稀疏文件简介 (1)稀疏文件(Sparse File):指的是文件中出现大量的0数据,这些数据对我们用处不大,但是却一样的占用空间.NTFS文件系统对此 ...

  3. Unity-WIKI 之 SplashScreen

    组件功能 在屏幕上的一个启动画面消失,等待几秒钟(或等待用户输入),然后淡出,下一个场景加载. 组件源码 using UnityEngine; using System.Collections; // ...

  4. Unity Sample Bootcamp

    M4枪 射击特效 Gun.js源码 function GenerateGraphicStuff(hit : RaycastHit) { var hitType : HitType; var body ...

  5. 安装StarUML 及使用时序图(Sequence Diagram)和用例图(use case diagram)

    时序图 用例图

  6. jquery中的get和set

    jquery中通过参数的个数来判断是get方法还是set方法: css: function(name, value ) { return value !== undefined ? jQuery.st ...

  7. 浅谈WebService返回数据效率对比

    原文链接 http://www.dotnetgeek.cn/xuexiwebservice1.html 一.什么是WebService: 简单通俗来说,就是企业之间.网站之间通过Internet来访问 ...

  8. Android 中调试手段 打印函数调用栈信息

    下面来简单介绍下 android 中的一种调试方法. 在 android 的 app 开发与调试中,经常需要用到打 Log 的方式来查看函数调用点. 这里介绍一种方法来打印当前栈中的函数调用关系 St ...

  9. 设计传说 PS零基础精通 Photoshop CC 2015视频教程

           课程目录: 课时1 Photoshop CC 2015 全面技能培训介绍  03:08课时2 1.1 PSCC工作区域及面板自定义 08:47课时3 1.2 图像文件的多种打开方式 0 ...

  10. 在matlab中进行地理坐标和像素坐标的相互转换

    clc;close all;clear; %地理坐标和像素坐标的相互转换 [pic,R]=geotiffread('boston.tif'); %读取带地理坐标信息的tif影像 [m,n,~]=siz ...