题目链接 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. 关于OAuth2.0 Authorization Code + PKCE flow在原生客户端(Native App)下集成的一点思考

    写在前面 前几天看了园友的一篇文章被广泛使用的OAuth2.0的密码模式已经废了,放弃吧 被再次提起: Implicit Flow Password Grant,均已被标记为Legacy,且OAuth ...

  2. python爬取网络中的QQ号码

    import urllib.request import ssl import re import os #博客地址:https://blog.csdn.net/qq_36374896 def wri ...

  3. vulhub漏洞环境搭建

    (搭建之前建议更换成阿里的源) 在纯净ubuntu中部署vulhub环境: 1.安装docker,并用docker -v命令验证安装结果: curl -s https://get.docker.com ...

  4. 关于MVC WebAPI 中加入任务调度功能的问题 (MVC WebAPI 任务调度)

    在MVC WebAPI中加入任务调度功能.即在MVC WebAPI启动时,启用任务调度程序. 但是这里有一个问题点,就是部署好IIS站点后,发现任务调度并没有启用.原因为何? 原因是部署好IIS站点后 ...

  5. UVA1389 Hard Life (01分数规划+最大流)

    UVA1389 Hard Life (01分数规划+最大流) Luogu 题目描述略 题解时间 $ (\frac{\Sigma EdgeCount}{\Sigma PointCount})_{max} ...

  6. Notion-douan:搭建自己的阅读清单

    前言 交完论文盲审稿,终于从接近一年的实习.秋招和论文的忙碌中闲下来. 在复盘秋招的时候发现自己虽然看过不少书,但缺少整理和思考,所以想趁这个机会梳理一下自己的阅读习惯,希望以后再读新的东西可以更系统 ...

  7. Linux 性能调优都有哪几种方法?

    1.Disabling daemons (关闭 daemons).    2.Shutting down the GUI (关闭 GUI).    3.Changing kernel paramete ...

  8. Java 建造者Builder

    import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; import java.u ...

  9. spring JDBC API 中存在哪些类?

    JdbcTemplate SimpleJdbcTemplate NamedParameterJdbcTemplate SimpleJdbcInsert SimpleJdbcCall

  10. 学习 MongoDB(一)

    1.介绍 MongoDB是C++语言编写,是一个基于分布式文件存储的开源数据库系统,MongoDB将数据存储为一个文档, 数据结构由键值对(key=>value)组成,MongoDB文档类似于 ...