Submission
Status:
PPPPPPPPPP
Score: 100
User: Cmoss9
Problemset: ของขวัญและขโมย
Language: cpp
Time: 0.002 second
Submitted On: 2025-03-29 23:46:44
#include <bits/stdc++.h>
using namespace std;
int main () {
ios_base::sync_with_stdio(0); cin.tie(NULL);
int n,k,t;
cin >> n >> k >> t;
int index = 1;
vector<bool> v(n+1,false);
while (true) {
//cout << index << ' ';
if (!v[index]) v[index] = true;
index = (index + k) % n;
if (index == 0) index = n;
if (index == t || index == 1) {
if (!v[index]) v[index] = true;
break;
}
}
int count = 0;
for (int i = 1;i<=n;i++) {
if (v[i]) count++;
}
cout << count;
}