Getting TLE in CLSLDR with O(n) approach

My solution is based on the josephus problem which gives solution in O(n) time but I am getting TLE.
My code is

#include <stdio.h>
int main(){
    int t;
    scanf("%d", &t);
	    int m, n, o;
	    scanf("%d %d %d", &n, &m, &o);
	    if(n == 1){
	    int ans = 1;
	    for(int i = 2; i <= n; ++i){
		    ans = (ans + o - 1)%i + 1;
	    printf("%d\n", (ans + m - 1)%n + 1);
    return 0; 

SORRY Guys my approach was actually taking O(tn) while it should be O(t) so i used hashing and the problem is solved now.

can you tell your approach now ,i have no idea