He gives you two positive integers A and B, and your task is to find all pairs of integers (C, D), such that A≤C≤B,A≤D≤B A≤C≤B,A≤D≤B and AB+BA≤CD+DC AB+BA≤CD+DC
Then in a new line, print an integer s indicating the number of pairs you find.
In each of the following s lines, print a pair of integers C and D. pairs should be sorted by C, and then by D in ascending order.
2 10 10 9 27
Case #1: 1 10 10 Case #2: 2 9 2727 9
AC代码:
#include<stdio.h> #include<cstdio> #include<string.h> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int main() { int t; scanf("%d",&t); for(int i=1;i<=t;i++) { char a[20],b[20]; cin>>a>>b; if(strcmp(a,b)==0) { printf("Case #%d:\n",i); printf("1\n"); cout<<a<<" "<<b<<endl; } else { printf("Case #%d:\n",i); printf("2\n"); cout<<a<<" "<<b<<endl; cout<<b<<" "<<a<<endl; } } return 0; }