Loading...  ## 题目链接 [](https://atcoder.jp/contests/abc290/tasks/abc290_d) ## solution 题目大意是给你一个n, d, k,从0开始,每次增加d,如果超出n就mod n,如果这个点已经经过过,那么就+1。 我们可以手写几个样例,发现每个回合有`g = n / gcd(n, d)`个,那么我们只需定位他在第几回合和某回合的第几个。那么第k个即`d * (k % g) % n + k / g` ```cpp #include<map> #include<set> #include<stack> #include<queue> #include<cmath> #include<vector> #include<bitset> #include<cstdio> #include<cstring> #include<fstream> #include<cstdlib> #include<iostream> #include<algorithm> #include<unordered_map> using namespace std; #define x first #define y second #define endl '\n' #define IOS \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); typedef long long ll; typedef pair<int,int> PII; typedef unsigned long long ull; const int INF = 0x3f3f3f3f, mod = 1000000007; const int N = 2e5 + 10; void solve(){ ll n, d, k; cin >> n >> d >> k; k--; ll g = n / __gcd(n, d); ll ans = d * (k % g) % n + k / g; cout << ans << endl; } int main(){ // IOS; int t = 1; cin >> t; while(t--){ solve(); } return 0; } ``` 最后修改:2023 年 05 月 22 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏