public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); int T=sc.nextInt(); System.out.println(f(n,k,T)); }
private static String f(int n, int k, int t) { int shu=1; int conut=0; int sum=0; for (int i = 0; i < t; i++) { for (int j = 0; j < n; j++) { shu+=conut; conut++; while(shu>k-1){ shu=shu-k; } if(j==0) sum+=shu; } } return sum+""; } }
public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNext()){ int n=sc.nextInt(); int k=sc.nextInt(); int t=sc.nextInt(); long sum=1,l=1,r=n,x=1; for (int i = 1; i < t; i++) { x+=(l+r)*n/2; x=x%k; sum+=x; l=1+i*n; r=n+i*n; } System.out.println(sum); } } }