- Educational Codeforces Round 104
- Educational Codeforces Round 80
- Educational Codeforces Round 81
- Educational Codeforces Round 78
- Educational Codeforces Round 54
- Educational Codeforces Round 54
- Educational Codeforces Round 35
- Educational Codeforces Round 36
- Educational Codeforces Round 69
- Educational Codeforces Round 98
B. Cat Cycle
直接模拟会超时,n为奇数时,每走n/2步相遇一次
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n,k;
cin>>n>>k;
if(n%2==0){
if(k%n==0) cout<<n<<endl;
else cout<<k%n<<endl;
}
else{
int x=n/2;
if(k>x){
if(k%x==0){
k=k/x-1+k;
}else
k=k/x+k;
}
if(k%n==0) cout<<n<<endl;
else cout<<k%n<<endl;
}
}
return 0;
}
网友评论