题目链接 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. JVM知识梳理

    JDK 是什么? JDK 是用于支持 Java 程序开发的最小环境. Java 程序设计语言 Java 虚拟机 Java API类库 JRE 是什么? JRE 是支持 Java 程序运行的标准环境. ...

  2. Java 代码注意细节

    代码优化的目标是: 1.减小代码的体积 2.提高代码运行的效率 代码优化细节 1.尽量指定类.方法的final修饰符 带有final修饰符的类是不可派生的.在Java核心API中,有许多应用final ...

  3. 常用命令行指令 Windows & Linux

    一.Linux linux常用命令详解:https://www.cnblogs.com/yuncong/p/10247583.html 挂载U盘到linux一个文件夹中 二.Windows 1.查看电 ...

  4. 4月11日 python学习总结 对象与类

    1.类的定义 #类的定义 class 类名: 属性='xxx' def __init__(self): self.name='enon' self.age=18 def other_func: pas ...

  5. Tomcat配置Context.xml上下文遇到的坑

    注意事项: 1. 在主机的 appBase 之外找到 WAR 和/或目录,并使用带有 docBase 属性的 context.xml 文件来定义它.避免双重部署导致出现不可预知的问题 {context ...

  6. SpringAOP 失效解决方案、Spring事务失效

    SpringAOP 失效解决方案 SpringAOP是基于代理来对目标方法进行增强,但是有的时候又会出现"增强无效"的情况,比如在@Transactional下的某类中的方法内调用 ...

  7. @Controller 注解?

    该注解表明该类扮演控制器的角色,Spring不需要你继承任何其他控制器基类或引用Servlet API.

  8. String 是最基本的数据类型吗?

    不是. Java中基本数据类型只有8个:byte.short.int.long.float.double.char.boolean:除了基本类型(primitive type),剩下都是引用类型(re ...

  9. 作为 务注册中心,Eureka比Zookeeper好在哪里?

    (1)Eureka保证的是可用性和分区容错性,Zookeeper 保证的是一致性和分区容错性 . (2)Eureka还有一种自我保护机制,如果在15分钟内超过85%的节点都没有正常的心跳,那么Eure ...

  10. Kafka 是如何实现高吞吐率的?

    Kafka是分布式消息系统,需要处理海量的消息,Kafka的设计是把所有的消息都写入速度低容量大的硬盘,以此来换取更强的存储能力,但实际上,使用硬盘并没有带来过多的性能损失.kafka主要使用了以下几 ...