题目链接 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. eclipse新建maven项目:'Building' has encountered a problem. Errors occurred during the build.

    二.eclipse 新建maven 项目报错(因为没有配置maven环境) 1.问题: ① 出现的问题1: Could not calculate build plan:Plugin org.apac ...

  2. 【网鼎杯2020青龙组】Web WriteUp

    AreUSerialz 打开题目直接给出了源代码 <?php include("flag.php"); highlight_file(__FILE__); class Fil ...

  3. 5分钟了解二叉树之LeetCode里的二叉树

    有读者反馈,现在谁不是为了找工作才学的数据结构,确实很有道理,是我肤浅了.所以为了满足大家的需求,这里总结下LeetCode里的数据结构.对于我们这种职场老人来说,刷LeetCode会遇到个很尴尬的问 ...

  4. Arthas之类操作

    Arthas之类操作 1. classLoader 查询当前JVM中存在的classloader classloader name numberOfInstances loadedCountTotal ...

  5. Mysql查询优化器之关于JOIN的优化

    连接查询应该是比较常用的查询方式,连接查询大致分为:内连接.外连接(左连接和右连接).自然连接 下图展示了 LEFT JOIN.RIGHT JOIN.INNER JOIN.OUTER JOIN 相关的 ...

  6. Oracle Yum源

    仓库地址(非Yum源仓库):https://public-yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/index.html 如何连接到 Orac ...

  7. notify()和 notifyAll()有什么区别?

    当一个线程进入 wait 之后,就必须等其他线程 notify/notifyall,使用 notifyall,可 以唤醒所有处于 wait 状态的线程,使其重新进入锁的争夺队列中,而 notify 只 ...

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

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

  9. 打败算法 —— 环形链表 II

    本文参考 出自LeetCode上的题库 -- 环形链表II,哈希表和快慢指针两种解法都需要O(n)的时间,但快慢指针仅占用O(1)的空间 https://leetcode-cn.com/problem ...

  10. OpenCV - Add Noise的一些方法

    噪声常用有两种:一种椒盐噪声,一种高斯噪声. import numpy as np def pepper_and_salt(src, proportion): """ : ...