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> ...
随机推荐
- 关于java实现同步的方法
什么是线程同步? 当使用多个线程来访问同一个数据时,非常容易出现线程安全问题(比如多个线程都在操作同一数据导致数据不一致),所以我们用同步机制来解决这些问题. 实现同步机制有两个方法: 1. 同步代码 ...
- centos_Error: Protected multilib versions_解决方法
在yum命令后面加入忽略参数:--setopt=protected_multilib=false you can also use --setopt=protected_multilib=false ...
- android之模拟器更新底层
Android源码修改,编译后得到system.img 替换\AndroidSDK\system-images\android-21\android-tv\armeabi-v7a\目录中的system ...
- windows server 2012R2 网络慢的那些事
前段时间公司新采购了一台ibm的服务器,装的是 windows server 2012R2, 在做完项目迁移后,发现项目访问数据库缓慢,于是逐项查找原因,最后终于找到解决办法 以Administrat ...
- JS学习笔记——标准对象
一.对象 在js中万物皆对象. 二.对象类型 number.string.boolean.undefined.function.object等 用typeof来获取对象的类型 如: alert( ty ...
- JDK Tools - xjc: 将 XML Schema 编译成 Java 类
xjc 是 JAXB 将 xsd 生成 Java 类的工具. 命令格式 xjc [ options ] schema file/URL/dir/jar ... [-b bindinfo ] ... 命 ...
- JDK Tools - jinfo: Java 配置信息工具
jinfo 是 JDK 自带的配置信息工具,可以查看.设置 Java 进程的参数配置. 命令格式 jinfo [ option ] pidjinfo [ option ] executable cor ...
- struts2中<s:property>的用法
1,访问Action值栈中的普通属性: <s:property value="attrName"/> 2,访问Action值栈中的对象属性(要有get set方法): ...
- cannot convert from '_TCHAR *' to 'char *'
Reference: Why can't convert TCHAR* to char* Need to Use Multi-Byte Character Set in project's setti ...
- Demo02_对结构体进行文件读写_张仕传_作业_
#include <iostream> using namespace std; #define StructArrarySize 5 // 老师数量 #define StudentNum ...