Skip to content

Instantly share code, notes, and snippets.

@kik
Created April 15, 2012 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kik/2391811 to your computer and use it in GitHub Desktop.
Save kik/2391811 to your computer and use it in GitHub Desktop.
GCJ 2012 Qual C
#include <iostream>
#include <set>
using namespace std;
int main()
{
int T;
cin >> T;
for (int cas = 1; cas <= T; cas++) {
int a, b;
cin >> a >> b;
int res = 0;
int dd;
for (dd = 1; dd <= a; dd *= 10)
;
for (int x = a; x < b; x++) {
set<int> st;
for (int d = 10; d <= a; d *= 10) {
int y = x / d + x % d * (dd / d);
if (x < y && y <= b) st.insert(y);
}
res += st.size();
}
cout << "Case #" << cas << ": " << res << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment