Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
1st
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define mp make_pair #define pb push_back #define pii pair<int, int> ll n, k, v; int gcd(ll a, ll b){ if(b == 0) return a; return gcd(b, a%b); } vector<int> solve(int i, ll timer){ //cout << i << " " << timer << endl; vector<int> trms; for(int j = 0; j < timer; j++) for(int k = 0; k < n; k++) trms.pb(k); vector<int> ans; i = i*k - 1; int j = k; while(j--) ans.pb(trms[i--]); return ans; } int main(){ ios_base :: sync_with_stdio(0); cin.tie(0); int t; cin >> t; for(int i = 1; i <= t; i++){ cin >> n >> k >> v; vector<string> a(n); for(int j = 0; j < n; j++) cin >> a[j]; ll g = gcd(n, k); ll timer = n*k/g; int x = v%timer; if(x == 0) x = timer; vector<int> ind = solve(x, timer); sort(ind.begin(), ind.end()); cout << "Case #" << i << ": "; for(auto i : ind) cout << a[i] << " "; cout << endl; } return 0; }
run
|
edit
|
history
|
help
0
ww999
march long ques 4
bharat
Sekhejane link
Próba
11aa11
Buenos Amigos
PrePostIncrOp
Scemo
Continuous Sub Set with given sum