日期:2014-05-20 浏览次数:20797 次
import java.util.*; public class Main { public static void main(String[] args) throws Exception{ int x=0,y=0,m=0,n=0,l=0,count = 0; Scanner cin = new Scanner(System.in); x = cin.nextInt(); y = cin.nextInt(); m = cin.nextInt(); n = cin.nextInt(); l = cin.nextInt(); if(m==n){ System.out.println("Impossible"); return; } while (x!=y) { count++; x+=m; y+=n; if (x>l-1) { x=x%l; } if (y>l-1) { y=y%l; } } System.out.println(count); } }