Educational Codeforces Round 104 div2 B. Cat Cycle
备注
翻着翻着找到这篇草稿。。
code
//Siberian Squirrel
//#include<bits/stdc++.h>
#include<unordered_map>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const double eps = 1e-7;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int N = 3e4 + 10;
const int UP = 1e2 + 10;
int a[UP];
inline int solve(int n, int k, ll res = 0) {
if(n == 3) {
if(k % 3 == 0) return 2;
if(k % 3 == 1) return 1;
if(k % 3 == 2) return 3;
}
int a = n, b = 1;
if(a & 1) {
int t = k / (n / 2), modd = k % (n / 2);
if(modd == 0) t --;
return (k + t) % n == 0? n: (k + t) % n;
} else {
return k % n == 0? n: (k % n);
}
}
int main() {
#ifdef ACM_LOCAL
freopen("input", "r", stdin);
freopen("output", "w", stdout);
#endif
int o = 1, n, m, k;
scanf("%d", &o);
while(o --) {
scanf("%d%d", &n, &k);
printf("%d\n", solve(n, k));
}
return 0;
}