REPEAT: Odd Repeat 

Problem:

Chef has an array consisting of N+K−1N+K−1 integers. The array contains only the first NN positive odd numbers. Each number appears exactly once, except for one number which appears exactly KK times. The sum of integers in Chef’s array is equal to SS.

Solution:

#include <iostream>
using namespace std;

int main() {
	long long T,N,K,S;
	cin>>T;
	while(T--){
	    cin>>N>>K>>S;
	    int x=1;
	    while(N--){
	        S-=x;
	        x+=2;
	    }
	    x=1;
	    while(x*(K-1)!=S){
	        x+=2;
	    }
	    cout<<x<<"\n";
	}
}
See also  FACEDIR: Find the Direction