题目链接 https://codeforces.com/contest/1506/problem/A

原题

1506A - Strange Table

Example
input
5
1 1 1
2 2 3
3 5 11
100 100 7312
1000000 1000000 1000000000000
output
1
2
9
1174
1000000000000

题解

先竖列竖列地排数字, 找到x所在的位置s1;

再横行横行地排, 找到s1位置的值并输出

 -----> 

(n为总行数, m为总列数, x为要找的数)

结果 = (行数-1)*m+第几列

求行: 要找到这个数的上一行, 这样用取余(x-1) % n, 比如

10, 我们要得到的是(行数-1) = 0

11, 我们要得到的是(行数-1) = 1

12, 我们要得到的是(行数-1) = 2

 求列: 用除法(x-1) / n+1, 看下上面的图应该就会了

代码

#include <iostream>

using namespace std;
typedef long long ll;
int main()
{
int t;
cin >> t;
while(t --)
{
ll n ,m,x;
scanf("%lld%lld%lld", &n, &m, &x); ll l = (x-1) / n+1;
ll r = (x-1) % n; cout << r*m+l << endl;
}
return 0;
}

Codeforces Round #710 (Div. 3) Editorial 1506A - Strange Table的更多相关文章

  1. Codeforces Round #590 (Div. 3) Editorial

    Codeforces Round #590 (Div. 3) Editorial 题目链接 官方题解 不要因为走得太远,就忘记为什么出发! Problem A 题目大意:商店有n件商品,每件商品有不同 ...

  2. 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table

    题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...

  3. Codeforces Round #747 (Div. 2) Editorial

    Codeforces Round #747 (Div. 2) A. Consecutive Sum Riddle 思路分析: 一开始想起了那个公式\(l + (l + 1) + - + (r − 1) ...

  4. Codeforces Round #425 (Div. 2) Problem C Strange Radiation (Codeforces 832C) - 二分答案 - 数论

    n people are standing on a coordinate axis in points with positive integer coordinates strictly less ...

  5. Codeforces Round #430 (Div. 2) Vitya and Strange Lesson

    D.Vitya and Strange Lesson(字典树) 题意: 给一个长度为\(n\)的非负整数序列,\(m\)次操作,每次先全局异或\(x\),再查询\(mex\) \(1<=n< ...

  6. Codeforces Round #544 (Div. 3) Editorial C. Balanced Team

    http://codeforces.com/contest/1133/problem/Ctime limit per test 2 secondsmemory limit per test 256 m ...

  7. Codeforces Round #453 ( Div. 2) Editorial ABCD

    A. Visiting a Friend time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. Codeforces Round #448(Div.2) Editorial ABC

    被B的0的情况从头卡到尾.导致没看C,心情炸裂又掉分了. A. Pizza Separation time limit per test 1 second memory limit per test ...

  9. Codeforces Round #710 (Div. 3)

    emmm,就ac了3题 A题转换推下公式. tB题模拟,在第一个与最后一个变x后,直接i下标+k,判断当前下标前一个befor与最后一个last距离是否>k,是的话在当前下标往前找*字符然后改为 ...

随机推荐

  1. TLS 1.0 至 1.3 握手流程详解

    概述 TLS 全称为 Transport Layer Security(传输层安全),其前身是 SSL,全称为 Secure Sockets Layer(安全套接字层),它的作用是为上层的应用协议提供 ...

  2. Linux安装docker 配置Apache

    镜像下载.域名解析.时间同步请点击 阿里云开源镜像站 要求: 安装docker yum install docker -y 将centos镜像导入云主机 将centos镜像导入docker docke ...

  3. ZYNQ生成一个工程的基本步骤

    Zynq 7000 SoC 是业界首款All Programmable SoC 组成: PL(FPGA部分) PS(ARM部分) PL和PS数据传输的 高效接口:AXI和ACP PS: 处理系统(Pr ...

  4. el-upload用form的方式多文件上传的方法

    使用el-upload组件遇到的坑. 1.第一种感觉最好,首先多个文件是一个http请求,另外还可以传除文件外其他的参数,但是没有进度条了. 发送请求的部分没有注释的部分是我分装了调后台的api,注释 ...

  5. Ubuntu- 彻底干净卸载MySQL、Apache2、Php的方法

    一.卸载删除 mysql 1 sudo apt-get autoremove --purge mysql-server-5.0 2 sudo apt-get remove mysql-server 3 ...

  6. CF1504X Codeforces Round #712

    CF1504D Flip the Cards(找规律+贪心) 题目大意:给你n张牌,正反面都有数字,保证所有牌上的数字在$[1,2n]$内且互不相同.你可以翻转任意张牌,接下来需要把牌按正面的数字从小 ...

  7. 以B tree和B+ tree的区别来分析mysql索引实现

    B树是一种多路自平衡搜索树,它类似普通的二叉树,但是B书允许每个节点有更多的子节点.B树示意图如下: Paste_Image.png B树的特点: (1)所有键值分布在整个树中 (2)任何关键字出现且 ...

  8. Dubbo 使用过程中都遇到了些什么问题?

    在注册中心找不到对应的服务,检查 service 实现类是否添加了@service 注解 无法连接到注册中心,检查配置文件中的对应的测试 ip 是否正确

  9. java-第三方工具去做一些校验

    推荐大家使用第三方 jar 的工具类去做判空.比如:从 Map 中取一个 key 的值,可以用 MapUtils 这个类:对字符串判空使用 StringUtils 这个类:对集合进行判空使用 Coll ...

  10. 面试题目:手写一个LRU算法实现

    一.常见的内存淘汰算法 FIFO  先进先出 在这种淘汰算法中,先进⼊缓存的会先被淘汰 命中率很低 LRU Least recently used,最近最少使⽤get 根据数据的历史访问记录来进⾏淘汰 ...