codeforces 390D Inna and Sweet Matrix
几个小结论:
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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- codeforces 390E Inna and Large Sweet Matrix
本题的主要算法就是区间更新和区间求和: 可以用线段树和树状数组来做: 感觉线段树写的太麻烦了,看到官方题解上说可以用树状数组做,觉得很神奇,以前用过的树状数组都是单点维护,区间求和的: 其实树状数组还 ...
- CodeForces 390E Inna and Large Sweet Matrix(树状数组改段求段)
树状数组仅仅能实现线段树区间改动和区间查询的功能,能够取代不须要lazy tag的线段树.且代码量和常数较小 首先定义一个数组 int c[N]; 并清空 memset(c, 0, sizeof c) ...
- 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 ...
- codeforces C. Inna and Huge Candy Matrix
http://codeforces.com/problemset/problem/400/C 题意:给你一个n*m的矩阵,然后在矩阵中有p个糖果,给你每个糖果的初始位置,然后经过x次顺时针反转,y次旋 ...
- codeforces C. Inna and Huge Candy Matrix 解题报告
题目链接:http://codeforces.com/problemset/problem/400/C 题目意思:给出一个n行m列的矩阵,问经过 x 次clockwise,y 次 horizontal ...
- codeforces round #234B(DIV2) B Inna and New Matrix of Candies
#include <iostream> #include <vector> #include <string> #include <algorithm> ...
随机推荐
- Apple Watch: WatchKit 应用程序要点
Apple Watch: WatchKit 应用程序要点 本文译自:Apple Watch: WatchKit App Essentials WatchKit 应用程序架构 上一篇文章简单介绍了 Wa ...
- php中的作用域
在php中分为局部变量.全局变量和静态变量: 局部变量就是在函数体内声明的变量,例子: <?php //作用域 $a=5; function show($b){ $a=$b;//相当于 ...
- java web和asp.net哪个做网站好
asp.net上手容易但是精通困难,因为微软把控件都封装好,你只管用就行了,但是想学习它的原理很困难,asp.net一般适合快速开发一个项目.java web上手困难但比较容易学的深入,因为所有的东西 ...
- ASP保存远程图片文件到本地代码
<% Function SaveRemoteFile(LocalFileName,RemoteFileUrl) SaveRemoteFile=True dim Ads,Retrieval,Get ...
- ASP实现https和http之间转化
HTTPS 是一个安全通信信道,用于在客户计算机和服务器之间交换信息.它使用安全套接字层 (SSL). HTTPS (Secure Hypertext Transfer Protocol) 安全超文本 ...
- python学习第二天:数字与字符串转换及逻辑值
1.数字与字符串的转化 #1.数字转字符,使用格式化字符串: *1.demo = ‘%d’ % source *2.%d整型:%f 浮点型 :%e科学计数 ...
- Meteor错误:TypeError: Meteor.userId is not a function
问题描述: 浏览器console提示错误TypeError: Meteor.userId is not a function. 原因分析: 通过查看Meteor API文档,可知该函数由包accoun ...
- yield关键字的用法
在上一篇文章中,说了下foreach的用法,但是还是比较复杂的,要实现接口才能进行遍历,有没有简单些的方法呢?答案是肯定的.且看下面. yield关键字的用法: 1.为当前类型添加一个任意方法,但是要 ...
- 12天学好C语言——记录我的C语言学习之路(Day 2)
12天学好C语言--记录我的C语言学习之路 Day 2: 我建议大家每一天学习之前都仅凭记忆去敲前一天敲过的最后一个程序,或者敲前一天你认为最难最长的一个程序,如果一晚上的睡眠之后不看书还能敲的出来, ...
- org.apache.catalina.connector.ClientAbortException
记个tomcat常见流输出中断异常 org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Conn ...