-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrange_table.cpp
More file actions
51 lines (40 loc) · 1.04 KB
/
Strange_table.cpp
File metadata and controls
51 lines (40 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <fstream>
#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << "[" << *it << " = " << a << "]";
err(++it, args...);
}
#define MAXN ((ll)1e6+5)
#define MOD ((ll)1e9 + 7)
#define INF ((ll)1e18+3)
#define ll long long
#define pb push_back
#define _ << " " <<
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<ll,ll>
#define mid ((l+r)/2)
//#define int long long
ll tt =0 , n , m ,x , a, b;
void solve(){
cin >> n >> m >> x;
if( n * m == x){ cout << x<<endl;return;}
x--;
ll a = x / n ;
ll b= x % n ;
ll res= b * m + a + 1 ;
cout << res<<endl;
}
signed main()
{
cin>>tt;
while(tt--){
solve();
}
}