fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define MAX 1000
  4.  
  5. int main(){
  6. int a, b, c, d, k;
  7. cin>> a>> b;
  8. cin>> c>> d;
  9. cin>> k;
  10. int A[MAX][MAX];
  11. int l=0;
  12. int m=100;
  13. while(a<=b){
  14. for(int i=c; i<=d; i++)
  15. if((a+i)%k==0){
  16. A[l][0]= a;
  17. A[l][1]=i;
  18. int temp= abs(a-i);
  19. m= min(m, temp);
  20. l++;
  21. cout<<a<<" "<<i<<"\n";
  22. }
  23. a++;
  24. }
  25. //if(l!=0) cout<<m;
  26. //if(l==0) cout<<-1;
  27. return 0;
  28. }
  29. // 1 10 1 7 3
Success #stdin #stdout 0s 5280KB
stdin
1 10 1 7 3
stdout
1 2
1 5
2 1
2 4
2 7
3 3
3 6
4 2
4 5
5 1
5 4
5 7
6 3
6 6
7 2
7 5
8 1
8 4
8 7
9 3
9 6
10 2
10 5