Skip to content

Instantly share code, notes, and snippets.

@TPAKC
Created March 28, 2015 17:52
Show Gist options
  • Save TPAKC/c3bac60d0b81e81f24b0 to your computer and use it in GitHub Desktop.
Save TPAKC/c3bac60d0b81e81f24b0 to your computer and use it in GitHub Desktop.
import java.util.*;
import java.io.IOException;
public class olimp4 {
public static void main (String[] args) throws IOException
{
Scanner in = new Scanner(System.in);
long a = in.nextLong(), b = in.nextLong(),c = in.nextLong(),max=0;
for (long i = 1; i <=a/c; i++) {
if((i*c)%b==0)continue;
max+=i*c;
}
long t1 = a/b;
if(t1%2==1)max+=(t1+1)*b/2;
max+=t1/2*(t1+1)*b;
System.out.println(max%1000000007);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment