1 #include <stdio.h> 2 #include <set> 3 4 using namespace std; 5 6 int total = 0; 7 #define MAXN 1024 8 int que[MAXN]; 9 #define MOD 1000000007 10 main()11int main() { 12 long long v; 13 set<int> rs; 14 int h=0, i, ni, vv, rk; 15 while(1) { 16 printf("number>:"); 17 scanf("%lld", &v); 18 if (v<=0) { 19 printf("total: %d\n", total); 20 if (total) { 21 printf("Latest numbers are:"); 22 for (i=0; i<8&&i<total; i++) { 23 ni=h-1-i; if (ni<0) ni+=MAXN; 24 printf(" %d", que[ni]); 25 } printf("\n"); 26 } 27 } else { 28 que[h++]=v; if (h>=MAXN) h=0; 29 total++; 30 vv = (v*37)%MOD; 31 rs.insert(vv); 32 auto y = rs.lower_bound(vv); 33 rk = 0; 34 for (auto x = rs.begin(); x!=y; x++) rk++; 35 printf("your number has rank %d\n", rk+1); 36 } 37 } 38 return 0; 39 } 40