Skip to content

Instantly share code, notes, and snippets.

@kik kik/C.cc
Created Apr 15, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.