Created
March 28, 2015 17:52
-
-
Save TPAKC/c3bac60d0b81e81f24b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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