Created
January 4, 2016 16:11
-
-
Save Jack-Saleem/151f94da684b3b5e0913 to your computer and use it in GitHub Desktop.
Codeforces 92A Chips program in java
This file contains hidden or 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.Scanner; | |
public class Chips | |
{ | |
public static void main(String[] args) | |
{ | |
Scanner z=new Scanner(System.in); | |
int n=z.nextInt(); | |
int m=z.nextInt(); | |
int temp=0; | |
for(int i=1;i<=n;i++) | |
{ | |
m-=i; | |
if(m==0){ | |
System.out.println(0);break; | |
} | |
if(m<0){ | |
System.out.println(temp);break; | |
} | |
temp=m; | |
if(i==n) | |
i=0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment