题目链接 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. .net Core 调用EF Core 爬坑

    .net Core 中调用 EF Core项目 首先得建一个类库供.net Core 的主项目引用:其次,在.net Core 中做注入:最后,在页面中调用 1.类库项目中的操作 1.新建类库项目 2 ...

  2. 创建一个 20G 的分区,并格式化为 ext4 文件系统

     创建一个 20G 的分区,并格式化为 ext4 文件系统,并完成如下要求: (1)block 大小为 2048,预留空间 20%,卷标为 MYDATA #fdisk /dev/sdb -->n ...

  3. xss平台搭建

    1. xss平台搭建 l 将xss平台源码放置在网站目录下 l 进入MySQL管理界面中的phpMyAdmin界面,新建一个XSS平台的数据库 l 修改XSS源码文件目录下的config.php中的数 ...

  4. TetBrains产品快捷键大全

     快捷键大全

  5. Python中的鸭子类型

    今天,我们来聊一聊Python中的鸭子类型(duck typing). 编程语言具有类型概念,例如Python中有数字类型.字符串类型.布尔类型,或者更加复杂的结构,例如元组tuple.列表list. ...

  6. java-StringBuilder

    一个可变的字符序列. String类的对象内容不可以改变,所以每当进行字符串恶拼接时,总是会在内存中创建一个新的对象,所以经常改变内容的字符串 所以最好不要用String,因为每次生成的对象都会对系统 ...

  7. 学习openstack(六)

    VIII openstack(1) 传统的数据中心面临的问题:成本.效率(要快).管理方面(物理机.云主机): 云计算:对运维需求总体量是减少了,尤其是硬件工程师,对运维的技术要求提高了: 云计算是个 ...

  8. sublime text3 好用的插件

    sublime text3 推荐插件 Package Controller安装 1.打开sublime text 3,按ctrl+~或者菜单View > Show Console打开命令窗口.2 ...

  9. 深入理解ES6之《用模块封装代码》

    什么是模块 模块是自动运行在严格模式下并且没有办法退出运行的Javascript代码 在模块的顶部this的值是undefined 其模块不支持html风格的代码注释除非用default关键字,否则不 ...

  10. Android中的Preference结构的设计与实现

    本文主要通过分析源代码来分享Preference的设计和实现方式,让开发者们在今后更加顺手地使用和扩展Preference类,或者在设计其他类似的界面和功能时可以提供参考帮助. Preference概 ...