Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.lang.*;
- import java.io.*;
- public class Main
- {
- public static void main (String[] args) throws java.lang.Exception
- {
- Scanner sc = new Scanner (System.in);
- String s=sc.next();
- int n= s.length();
- 255 255 1 1135
- i=2
- j=5
- k=6
- for(int i=0; i<n; i++){
- for(int j= i+1; j<n; j++){
- for(int k =j+1; k<n-1; k++){
- long []ans= new long [4];
- ans[0]=0;
- for(int q=0;q<=i;q++){
- ans[0]*=10;
- int x=(s.charAt(q)-'0');
- ans[0]+=(long)x;
- }
- ans[1]=0;
- for(int q=i+1;q<=j;q++){
- ans[1]*=10;
- int x=(s.charAt(q)-'0');
- ans[1]+=(long)x;
- }
- ans[2]=0;
- for(int q=j+1;q<=k;q++){
- ans[2]*=10;
- int x=(s.charAt(q)-'0');
- ans[2]+=(long)x;
- }
- ans[3]=0;
- for(int q=k+1;q<n;q++){
- ans[3]*=10;
- int x=(s.charAt(q)-'0');
- ans[3]+=(long)x;
- }
- int flag=0;
- for(int p=0;p<4;p++)
- {
- // if(i==2 && j==5 && k==7)System.out.print(ans[p]+" ");
- if(ans[p]>255)flag=1;
- }
- if(flag==1 )continue;
- for(int p=0;p<3;p++)
- {
- System.out.print(ans[p]+".");
- }
- System.out.println(ans[3]);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement