CodeForces 625C K-special Tables
来源:互联网 发布:51单片机cy和ac 编辑:程序博客网 时间:2024/06/06 14:09
传送门:http://codeforces.com/problemset/problem/625/C
用1~n^2填充n*n的方阵,满足
所有的数都使用了一次
每一行的数是递增的
第k列的数的和尽量大
求满足的方阵
贪心,将1~k-1列先竖着填充1~n*(k-1)的数,然后k~n列横着填充
代码如下:
#include<cstdio>using namespace std;int n,k;int s[505][505];int ans=0;int main(){scanf("%d%d",&n,&k);int now=0;for (int i=1;i<=n;i++){for (int j=1;j<k;j++){now++;s[i][j]=now;}}for (int i=1;i<=n;i++){for (int j=k;j<=n;j++){now++;s[i][j]=now;if (j==k){ans+=now;}}}printf("%d\n",ans);for (int i=1;i<=n;i++){for (int j=1;j<=n;j++){printf("%d ",s[i][j]);}printf("\n");} return 0;}
0 0
- Codeforces 625C K-special Tables 【贪心】
- CodeForces 625C K-special Tables
- Codeforces 625C - K-special Tables
- CodeFOrces 625C - K-special Tables
- 【77.78%】【codeforces 625C】K-special Tables
- CodeForces 625 C. K-special Tables(水~)
- Codeforces Round #342 (Div. 2)--C. K-special Tables
- Codeforces Round #342 (Div. 2) 625C K-special Tables(脑洞)
- cf 625 C. K-special Tables (打表+规律)
- cf#342-C - K-special Tables-构造
- C. K-special Tables【构造】水
- Codeforces Round #342 (Div. 2)-C. K-special Tables(模拟)
- coderforces342C. K-special Tables
- CF#342(2) C. K-special Tables 贪心
- CodeForces 431C K-Tree
- CodeForces 431C k-Tree
- Ophcrack Tools and XP Special Tables
- CodeForces 489F Special Matrices
- Android事件分发机制完全解析,带你从源码的角度彻底理解(下)
- Ubuntu14.04 LTS安装QQ8.1
- 求最小公倍数的方法
- android getContext()、getApplicationContext()和this有什么区别
- OC修改文件夹的函数
- CodeForces 625C K-special Tables
- Android高效加载大图、多图解决方案,有效避免程序OOM
- R语言实战笔记
- Eclipse配置PyDev插件
- 夯实基础阶段:第一天:C/C++ 一星难度刷题
- maven 的 pom.xml 文件报错:ArtifactTransferException: Failure to transfer
- 【HDU5452】Minimum Cut
- 关于$.ajaxFileUpload()上传图片
- POJ1936——All in All