几个小结论:

1.路径长度=i+j-1;

2.最简单的走法是先横走再竖着走或者先竖着走再横着走

#include<cstdio>
#include<cstring>
using namespace std; void print(int x,int y)
{
for(int i=; i<=y; i++)
printf("(1,%d) ",i);
for(int i=; i<=x; i++)
printf("(%d,%d) ",i,y);
printf("\n");
} int main()
{
int n,m,k;
scanf("%d%d%d",&n,&m,&k);
int cnt=;
int ans=;
int l,i;
for(l=;; l++)
{
for(i=; i<=n&&i<l; i++)
{
if(l-i>m)continue;
ans+=l-;
cnt++;
if(cnt>=k)break;
}
if(cnt>=k)break;
}
printf("%d\n",ans);
// printf("%d %d\n",l,i);
for(; i>=; i--)
{
if(l-i>m)break;
print(i,l-i);
}
l--;
for(; l>=; l--)
for(i=; i<l&&i<=n; i++)
{
if(l-i>m)continue;
print(i,l-i);
}
return ;
}

codeforces 390D Inna and Sweet Matrix的更多相关文章

  1. Codeforces Round #234 (Div. 2) B. Inna and New Matrix of Candies

    B. Inna and New Matrix of Candies time limit per test 1 second memory limit per test 256 megabytes i ...

  2. Codeforces Round #234 (Div. 2) B. Inna and New Matrix of Candies SET的妙用

    B. Inna and New Matrix of Candies time limit per test 1 second memory limit per test 256 megabytes i ...

  3. Codeforces Round #234 (Div. 2):B. Inna and New Matrix of Candies

    B. Inna and New Matrix of Candies time limit per test 1 second memory limit per test 256 megabytes i ...

  4. codeforces 390E Inna and Large Sweet Matrix

    本题的主要算法就是区间更新和区间求和: 可以用线段树和树状数组来做: 感觉线段树写的太麻烦了,看到官方题解上说可以用树状数组做,觉得很神奇,以前用过的树状数组都是单点维护,区间求和的: 其实树状数组还 ...

  5. CodeForces 390E Inna and Large Sweet Matrix(树状数组改段求段)

    树状数组仅仅能实现线段树区间改动和区间查询的功能,能够取代不须要lazy tag的线段树.且代码量和常数较小 首先定义一个数组 int c[N]; 并清空 memset(c, 0, sizeof c) ...

  6. Codeforces 390E Inna and Large Sweet Matrix 树状数组改段求段

    题目链接:点击打开链接 题意:给定n*m的二维平面 w个操作 int mp[n][m] = { 0 }; 1.0 (x1,y1) (x2,y2) value for i : x1 to x2 for ...

  7. codeforces C. Inna and Huge Candy Matrix

    http://codeforces.com/problemset/problem/400/C 题意:给你一个n*m的矩阵,然后在矩阵中有p个糖果,给你每个糖果的初始位置,然后经过x次顺时针反转,y次旋 ...

  8. codeforces C. Inna and Huge Candy Matrix 解题报告

    题目链接:http://codeforces.com/problemset/problem/400/C 题目意思:给出一个n行m列的矩阵,问经过 x 次clockwise,y 次 horizontal ...

  9. codeforces round #234B(DIV2) B Inna and New Matrix of Candies

    #include <iostream> #include <vector> #include <string> #include <algorithm> ...

随机推荐

  1. Linux 的使用基础---Linux的常用命令

    自己电脑的安装的软件太多了,如果重装linux系统的话,是在是太麻烦了,本身电脑系统是32位的,硬件上的配置也行,所以就安装了虚拟机,在虚拟机上又安装了一个Linuxd 系统,虽然速度是有些慢,总比浪 ...

  2. 分布式算法(一致性Hash算法)

    一.分布式算法 在做服务器负载均衡时候可供选择的负载均衡的算法有很多,包括: 轮循算法(Round Robin).哈希算法(HASH).最少连接算法(Least Connection).响应速度算法( ...

  3. 通过spring来配置某个命令号和执行方法之间的映射

    整理的内容 1.手动获取spring的ApplicationContext和bean对象 写一个工具类实现ApplicationContextAware接口 2.反射的知识整理 3.前后端协议交互的时 ...

  4. ASP.NET Web Forms 4.5的新特性

    作者:Parry出处:http://www.cnblogs.com/parry/ 一.强类型数据控件 在出现强类型数据控件前,我们绑定数据控件时,前台一般使用Eval或者DataBinder.Eval ...

  5. 一步一步创建一个简单的Package(1)

    创建Package之前首先我们理解需求: 数据源是一组历史货币数据包含在平面文件SampleCurrencyData.txt中,源数据中有四列. 下面是SampleCurrencyData.txt文件 ...

  6. C#+ArcEngine 序列化和反序列化AE对象

    http://www.cnblogs.com/jindin/archive/2009/07/23/1529695.html 在AE开发过程,总是要将某些对象暂时存储起来,像element,layer, ...

  7. this 关键字

    导读 本文将列举C#中this关键字的用途 1.this 含义 2.用this 关键字避免参数与字段的混淆 3.用this关键字串联构造器 4.索引器 6.Visitor 模式 this 含义 C# ...

  8. 九度OJ 1348 数组中的逆序对 -- 归并排序

    题目地址:http://ac.jobdu.com/problem.php?pid=1348 题目描述: 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对.输入一个数组,求 ...

  9. 安装FreeMind

    Freemind 1.0.0 官方正式版下载地址:http://dl.pconline.com.cn/html_2/1/131/id=46751&pn=0.html 软件介绍: Freemin ...

  10. java.util.regx Demo

    import java.util.regex.Matcher;import java.util.regex.Pattern; public class TestRegex { public stati ...