CodeForces 625C K-special Tables
2016-02-14 00:28
232 查看
简单构造
#include <stdio.h> #include <algorithm> #include <string.h> #include <queue> #include <stack> #include <map> #include <vector> using namespace std; const int maxn=600; int n,m; int ans[maxn][maxn]; int main() { scanf("%d%d",&n,&m); int now=n*n; for(int i=n;i>=1;i--) { for(int j=n;j>=m;j--) { ans[i][j]=now; now--; } } for(int i=n;i>=1;i--) { for(int j=m-1;j>=1;j--) { ans[i][j]=now; now--; } } int sum=0; for(int i=1;i<=n;i++) { sum=sum+ans[i][m]; } printf("%d\n",sum); for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { printf("%d ",ans[i][j]); } printf("\n"); } return 0; }
相关文章推荐
- CodeForces 625B War of the Corporations
- CodeForces 625A Guest From the Past
- php unicode
- CodeForces 625D Finals in arithmetic
- 杭电1017
- Java线程学习经典例子-读写者演示
- 用Qt实现一个桌面弹幕程序(二)--实现一个弹幕①
- MOOC Machine learning 作业交流帖1
- 了解HTML CSS格式化排版 文字排版
- 禁止UITextField 使用粘贴复制功能
- 经典同步模型-生产者消费者java代码实现
- GDAL获取投影坐标系注意问题
- 1037. Magic Coupon (25)
- hdu2196 Computer(树型dp,两次bfs)
- UIStackView相关
- JSP中的EL隐式对象
- LeetCode 62. Unique Paths
- 寻路算法模拟器
- 手工matlab下K-means聚类算法实现而不是调用库函数
- 《Android源码设计模式》读书笔记 (5) 第5章 工厂模式